Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get this week's data using SQLite

I am trying to get this week's data in sqlite but it seems that I have missed something as i get wrong information back. To be more specific i want to retrieve all the data in my database that have a timestamp which its date falls in this week. This week may either start from Sunday or Monday i.e 26/2/12-03/03/12. At the moment I am using something like this: SELECT * FROM myTable WHERE DATE(timeStamp) == DATE('now', 'weekday 0', '-7 days')

like image 917
JustCurious Avatar asked Feb 28 '12 18:02

JustCurious


Video Answer


1 Answers

I think you should be pretty close. If you want everything since the start of this week, just a slight modification:

SELECT * FROM myTable WHERE DATE(timeStamp) >= DATE('now', 'weekday 0', '-7 days');
like image 197
barendt Avatar answered Oct 01 '22 00:10

barendt