eldan88 Posted January 10, 2014 Share Posted January 10, 2014 Hey Guys. I am trying to write a mysql query that just pulls the count for the last 7 days. I tried to run the SQL but it doesn't seem to be working. Do you guys have any suggestions? Thank you! Below is my SQL syntax SELECT COUNT(*) FROM checkout_page WHERE id = 1 AND DATE(checkout_date) < CURTIME() - INTERVAL 7 DAYS Link to comment https://forums.phpfreaks.com/topic/285262-need-help-pulling-records-for-the-last-7-days/ Share on other sites More sharing options...
Barand Posted January 10, 2014 Share Posted January 10, 2014 try > instead of < and use CURDATE() SELECT COUNT(*) FROM checkout_page WHERE id = 1 AND DATE(checkout_date) > CURDATE() - INTERVAL 7 DAYS Link to comment https://forums.phpfreaks.com/topic/285262-need-help-pulling-records-for-the-last-7-days/#findComment-1464738 Share on other sites More sharing options...
eldan88 Posted January 10, 2014 Author Share Posted January 10, 2014 Hey Bernard, Thanks for the post. I have tried that and I got the following error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DAYS' at line 1 Link to comment https://forums.phpfreaks.com/topic/285262-need-help-pulling-records-for-the-last-7-days/#findComment-1464761 Share on other sites More sharing options...
Barand Posted January 10, 2014 Share Posted January 10, 2014 Sorry - should be DAY, not DAYS Link to comment https://forums.phpfreaks.com/topic/285262-need-help-pulling-records-for-the-last-7-days/#findComment-1464762 Share on other sites More sharing options...
eldan88 Posted January 10, 2014 Author Share Posted January 10, 2014 Thanks a lot Barand!!! That worked!! Link to comment https://forums.phpfreaks.com/topic/285262-need-help-pulling-records-for-the-last-7-days/#findComment-1464763 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.