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);
}
我想获取全天有效的行,不是只有现在有效的行。我想获取这几天有效的所有的行。时间是从 00:00 到23:59:59。
如何实现?
或许下面的方法能帮的上你:
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);
WHERE TIMESTAMPDIFF(DAY,NOW(),startTimestamp)<=24
或者
WHERE DATEDIFF(startTimestamp,NOW()) <=24