根据日期从sqlite数据库中检索数据 [英] Retrieving data from sqlite database on the basis of date
问题描述
我想从sqlite数据库中检索一些数据。我使用了以下查询for papose
I want to retrieve some data from sqlite database. I used the following query for that pupose
SELECT * FROM tableName
它适用于我
但我想根据日期检索数据如下
It works fine for me
But I want to retrieve data on the basis of date as following
SELECT * FROM tableName WHERE date=09-09-2013
此查询显示无结果,因为Sqlite数据库中的日期列包含日期,例如
This query shows no result, because date column in Sqlite database contains dates like
1378307780519
1378350490627
1378381805222
1378383415433
1378387764681
我不知道它的日期格式。
任何人都告诉我如何根据用户提供的日期检索数据,就像
09-09- 2013或09/09/2013
如何将用户提供的日期与可以在该日期的基础上检索sqlite数据库日期和数据
先谢谢
I do not know what format of date it is.
Any one tell me how I can retrieve data according to user provided date just like
09-09-2013 or 09/09/2013
How user provided date can be compared with sqlite database date and data can be retrieved on the basis of that date
Thanks in Advance
推荐答案
也许你可以看这个页面:
MySQL日期和时间函数 [ ^ ]
Maybe you can watch this page:
MySQL Date and Time Functions[^]
SQLite日期和时间函数页面 [ ^ ]应该可以帮到你。
我猜你的数据库中的数字是毫安时间的UNIX纪元 - 删除最后三位数字给我一个最近的日期和时间:
The SQLite date and time functions page[^] should help you out.
I'm guessing the numbers you have in your database are UNIX epoch with milliseconds - removing the final three digits gives me a recent date and time:
sqlite> select datetime(1378307780519 / 1000, 'unixepoch');
2013-09-04 15:16:20
sqlite> select datetime(1378350490627 / 1000, 'unixepoch');
2013-09-05 03:08:10
这篇关于根据日期从sqlite数据库中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!