Jump to content

Query from the last 7 days


Leovenous

Recommended Posts

I would think this is both a common and easy question, but 2 hours of digging have not yielded any results yet, so here goes.

All I want, is a simple query to get data from a table that has been modified in the last 7 days.

I have a field called 'modified' that has a time stamp 0000-00-00 00-00-00. It seems to me I want a way to check the timestamps and grab which ones are less than 7 days old.

So the query might look something like:

[code]SELECT * FROM players WHERE modified  > (SUBDATE(CURDATE(), INTERVAL '7' DAY)[/code]

But obviously I'm bumping around in the dark.

Any help?
Link to comment
https://forums.phpfreaks.com/topic/14976-query-from-the-last-7-days/
Share on other sites

Yep. That worked, and it makes sense. I wonder why I have not been able to find examples of queries even similar. (shrugs)

Thanks a bunch guys. Here's the final query:

[code]$query = "SELECT * FROM players WHERE Creator_ID LIKE '$id' AND modified >= CURDATE( ) - INTERVAL 7 DAY";[/code]

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.