现在我有一个非常简单的SQL查询来检查是否有3个条件:
String flashcardSearchQuery = "SELECT * FROM " + TABLE_NAME + " WHERE " +
COLUMN_KNOW_FOREIGN_CHAR + " = 0 AND " +
COLUMN_KNOW_FOREIGN_ALT + " = 0 AND " +
COLUMN_KNOW_ENGLISH_WORD + " = 0";
现在我想再添加一个,我使用第四个SQL变量(COLUMN_SLEEP_DATE),但我想根据当前日期检查它,看看它已经过了多少天,即得到当前日期和存储之间的差值日期。
我不确定在flashcardSearchQuery
声明中是否可以做到这一点,所以在我尝试做这项工作之前,也许有人可以告诉我,如果我走在正确的道路上或者我是否应该在SQL之外做到这一点吗?
这是我必须以某种方式嵌入:(或类似的东西)
Calendar calendarNow = Calendar.getInstance();
Date rightNow = calendarNow.getTime();
long diff = 0;
try {
diff = Math.round((rightNow.getTime() -
df.parse(flashcard.getSleepDate()).getTime()) / (double) 86400000);
} catch (ParseException e) {
}