如果表结构是Date类型比较好办直接操作就可以了这个不多说;
如果表结构是String类型则需要在查询时把要查找的字段转换为Date来和其他的日期比较后作为查询条件
Cursor mCursor = db.query(true, DATABASE_SLEEP_TABLE,
new String[] { KEY_SLEEP_ROWID, KEY_SLEEP_START_DATE,
KEY_SLEEP_END_DATE, KEY_SLEEP_DEEPSLEEP,
KEY_SLEEP_LIGHTSLEEP, KEY_SLEEP_ONLINE },
" **strftime('%s', "+KEY_SLEEP_END_DATE+")** BETWEEN strftime('%s', '"+normalStartDate+"') AND strftime('%s', '"+normalEndDate+"') " +
"and strftime('%s', "+KEY_SLEEP_START_DATE+") BETWEEN strftime('%s', '"+normalStartDate+"') AND strftime('%s', '"+normalEndDate+"')"
+"or strftime('%s', "+KEY_SLEEP_START_DATE+")<= strftime('%s', '"+normalStartDate+"')" +
" and strftime('%s', "+KEY_SLEEP_END_DATE+") BETWEEN strftime('%s', '"+normalStartDate+"') AND strftime('%s', '"+normalEndDate+"') "
+" or strftime('%s', "+KEY_SLEEP_END_DATE+")>=strftime('%s', '"+normalEndDate+"')" +
"and strftime('%s', "+KEY_SLEEP_START_DATE+") BETWEEN strftime('%s', '"+normalStartDate+"') AND strftime('%s', '"+normalEndDate+"')" ,
null, null, null, null, null);
strftime(‘%s’, “+KEY_SLEEP_END_DATE+”)就是把String字段转变为日期Date来进行比较操作