ActiveAndroid icon indicating copy to clipboard operation
ActiveAndroid copied to clipboard

How to select two dates in where clause start and end of the month

Open spatil063 opened this issue 9 years ago • 5 comments

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;

}

spatil063 avatar Nov 18 '16 13:11 spatil063

did u solve your problem? If yes post solution, pls :)

luna-vulpo avatar Mar 06 '17 13:03 luna-vulpo

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 .

spatil063 avatar Mar 06 '17 13:03 spatil063

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()

azizimusa avatar Feb 26 '20 01:02 azizimusa

thx. But now we rid the ActiveAndroid from project.

luna-vulpo avatar Apr 14 '20 08:04 luna-vulpo

name = "timestamp", index = true) private String timestamp; timestamp is format will be work!

csr91706 avatar Sep 03 '22 03:09 csr91706