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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted January 10, 2014 Solution Share Posted January 10, 2014 Sorry - should be DAY, not DAYS Quote Link to comment Share on other sites More sharing options...
eldan88 Posted January 10, 2014 Author Share Posted January 10, 2014 Thanks a lot Barand!!! That worked!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.