SQLite查询日期等于今天 [英] SQLite Query For Dates Equals Today
问题描述
如何进行查询以仅从数据库中检索时间等于今天的记录。我将日期保存很长时间。
How to make the query to retrieve from database only the records that have the time equals to 'today'. I store my dates as long.
例如:
DateColumn(列的名称),表的名称为MyTable
E.g: DateColumn (The name of my column) and the name of my table is MyTable
1360054701278(格林尼治标准时间2013年2月5日,星期二8:58:21)
1359795295000(格林尼治标准时间2013年2月2日,星期六,上午8:54:55)
1360054701278 (Tuesday, February 5, 2013 8:58:21 AM GMT) 1359795295000 (Saturday, February 2, 2013 8:54:55 AM GMT)
那么我应该如何查询此示例以检索第一条记录(因为它是等于今天的日期)?
So how should I make the query for this example in order to retrieve the first record (because it is the date equal to today)?
任何建议将不胜感激。
谢谢
Any suggestion would be appreciated. Thanks
推荐答案
对不起,您的问题是您的列中节省了额外的毫秒数。
sorry for not seeing that, your problem were the additional milliseconds saved in your column.
解决方案是按除法删除它们;-)
The solution was to remove them by division ;-)
SELECT * FROM MyTable WHERE date(datetime(DateColumn / 1000 , 'unixepoch')) = date('now')
这篇关于SQLite查询日期等于今天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!