1

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`
4

3 回答 3

4

利用date

select timestamp, pname 
from attendance 
where date(timestamp) = '2013-03-06'
于 2013-05-20T11:13:45.287 回答
1

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.

于 2013-05-20T11:46:50.097 回答
0

SQLite 支持函数date,可用于获取时间戳的日期部分。例如:

SELECT * FROM mytable WHERE date(timestamp_col) = '2013-05-20'

有关更多信息,请参阅SQLite 日期和时间函数文档

于 2013-05-20T11:15:18.280 回答