How to select two dates in where clause start and end of the month
Actually i am developing the app where i required to add the amount from start of the month till end of the month.
Below find my Query which i have tried
.where("date(datetime(collectionDate / 1000 , 'unixepoch')) BETWEEN date('now','start of month') and date('now','start of month','+one month','-one day')").execute(); ..where("date(datetime(collectionDate / 1000 , 'unixepoch')) BETWEEN date('start of month') and date('now')")
Both I have tried but nothing works
Belwo find Model
@Table(name = "Collection") public class CollectionModel extends Model {
@Column(name = "userLoginId")
public String userLoginId;
@Column(name = "collectionDate")
public Date collectionDate;
@Column(name = "accountLedgerId")
public Double accountLedgerId;
// C = Cash, B = Cheque, N = Non Payment
@Column(name = "collectionStatus", length = 1)
public String collectionStatus;
@Column(name = "againstBillNo", length = 20)
public String againsBillNo;
@Column(name = "collectionAmount")
public Double collectionAmount;
@Column(name = "chequeNo")
public Integer chequeNo;
@Column(name = "chequeDated")
public Date chequeDated;
@Column(name = "nextVisit")
public Date nextVisit;
@Column(name = "prefVisitTime", length = 5)
public String prefVisitTime;
@Column(name = "nonPaymentRemark")
public String nonPaymentRemark;
}
did u solve your problem? If yes post solution, pls :)
no.Are r u having NY SOLUTION FOR THAT
On Mon, Mar 6, 2017 at 6:32 PM, luna-vulpo [email protected] wrote:
did u solve your problem? If yes post solution, pls :)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pardom/ActiveAndroid/issues/503#issuecomment-284389911, or mute the thread https://github.com/notifications/unsubscribe-auth/AV33yeaoJejsH_lADoAsZpIc4udwd5ISks5rjAPYgaJpZM4K2f0d .
You are doing it wrongly. Please refer the basic query. It should be like this:
String s = "start of month"; String d = "end of month";
Example 1 // date after start of month
.where("collectionDate > ?", s).execute()
Example 2 // select specific month only
.where("collectionDate BETWEEN ? AND ?", s, d).execute()
thx. But now we rid the ActiveAndroid from project.
name = "timestamp", index = true) private String timestamp; timestamp is format will be work!