doni49 Posted March 4, 2011 Share Posted March 4, 2011 I have a mySQL DB that includes several tables. One of those tables includes a column for TIMESTAMPS (the timestamp showing when the row was inserted into the DB. I need to figure out how to get it to show the last FIVE DAYS worth of data. There could be 10 records or there could be twenty, but I just need all the records with a timestamp from the past 5 days. TIA! Quote Link to comment https://forums.phpfreaks.com/topic/229545-select-last-five-days-worth-of-data/ Share on other sites More sharing options...
Pikachu2000 Posted March 4, 2011 Share Posted March 4, 2011 As long as the timestamp is in the native MySQL YYYY-MM-DD format, this syntax ought to do the trick. SELECT `field` FROM `table` WHERE `timestamp_field` > DATE_SUB(CURDATE(), INTERVAL 5 DAY) Quote Link to comment https://forums.phpfreaks.com/topic/229545-select-last-five-days-worth-of-data/#findComment-1182653 Share on other sites More sharing options...
doni49 Posted March 19, 2011 Author Share Posted March 19, 2011 Thanks for the help and sorry for the delayed response. I just got back home last night. Quote Link to comment https://forums.phpfreaks.com/topic/229545-select-last-five-days-worth-of-data/#findComment-1189369 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.