I have created a database for my application and I use timestamp
(yyyy-MM-dd HH:mm:ss) as an attribute of my table. How can I basically query the database to get the last 7 days results?
I was thinking something like that SELECT * FROM myTable WHERE date('now','-7 days')
but it doesnt seem to work since i dont actually compare it with my timestamp.
Asked
Active
Viewed 1,771 times
1

JustCurious
- 1,848
- 3
- 30
- 57
-
May be this link will help you. http://stackoverflow.com/questions/289680/difference-between-2-dates-in-sqlite – kosa Jan 17 '12 at 23:48
1 Answers
0
SQLite only has very few Date and Time Functions. So your best bet would be creating two compatible datetime strings in the format YYYY-MM-DD HH:MM:SS
(one for today and one for one week ago). Then feed those values to a SQLite query (you can compare with <
or >
).

ChristopheD
- 112,638
- 29
- 165
- 179