Reputation: 20906
public Cursor getRowsBetweenDate(Date startAt, Date endAt) {
String selection = KEY_START_AT + " >= time('now', 'localtime') AND " + KEY_END_AT + " <= time('now', 'localtime')";
return sqLiteDatabase.query(TABLE_NAME, null, selection, null, null, null, null);
}
but i want the whole day, not valid just now. I want to get all rows that are valid this day. So from 00:00 to 23:59:59
How can I do this?
EDIT:
thank you. Any what if day is not now but some other day as input param?
Upvotes: 1
Views: 201
Reputation: 46943
Maybe try something like:
String where = "strftime('%d.%m.%Y', date(?)) = strftime('%d.%m.%Y', 'now')";
SimpleDateFormat dateFormat = "yyyy-MM-dd";
String [] whereArgs = {dateFormat.format(KEY_END_AT) };
cursor = sqLiteDatabase.query(TABLE_NAME, null, where , whereArgs, null,
null, null);
All of this is typed out only via searchign through documentation and I might have some stupid typo. Please write back if any problems.
EDIT Actually Harry Joy's idea seems easier, but I will be leaving my comment here, becasue it might be useful if you are interested in grouping in something other than days.
Upvotes: 1