Jump to content

SELECT last five days worth of data?


doni49

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/229545-select-last-five-days-worth-of-data/
Share on other sites

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)

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.