07:00 06/03/13
我正在使用 SQLite,例如,如果我有一个具有此值的 timestamp 列但我只想选择 where timestamp ,我现在如何选择一个查询06/03/13
。
这是我的查询示例..
select
timestamp, pname
from
attendance
where
timestamp between `06/01/13` and `06/10/13`
利用date
select timestamp, pname
from attendance
where date(timestamp) = '2013-03-06'
When filtering on a timestamp column, you want this logic.
where YourField >= TheStartOfYourRange
and YourField < TheDayAfterTheEndOfYourRange
This is equivalent to the two answers that use the date() function, but will generally perform faster. Using functions in the where clause usually slows down production, especially on indexed fields.
SQLite 支持函数date
,可用于获取时间戳的日期部分。例如:
SELECT * FROM mytable WHERE date(timestamp_col) = '2013-05-20'
有关更多信息,请参阅SQLite 日期和时间函数文档。