我想要它,以便当用户选择日期时,我的SQLite数据库仅显示该日期的信息。
答案 0 :(得分:3)
取决于您如何存储日期信息。如果您将其存储为“2012-01-19 16:20:00”之类的字符串,那么您可以使用它来获取它们:
SELECT * FROM events WHERE event_time LIKE "2012-01-19%" ORDER BY event_time;
在Android中你可能会做这样的事情:
String[] whereVars = new String[] {"2012-01-19%"};
String where = "event_time LIKE ? ";
dbHandle.rawQuery("SELECT * FROM event WHERE " + where + " ORDER BY event_time", whereVars);
答案 1 :(得分:0)
这样的东西?
select *
from myTable
where myDateColumn between (Date(myDate, 'localtime'), date(myDate,'localtime','+1 day')