PHP and Mysql Date Question

Associate
Joined
13 Nov 2003
Posts
1,567
Location
Manchester
Hi All

I am trying to make a query that will recall all records from a database where an mysql date field is 7 days earlier than the current date. Ie 7 days have passed since the date in the field.

Is there a simple way to do this?

Any advice appreciated

Thanks
Aaron
 
Why's that confusing :/

Code:
SELECT *
FROM table
WHERE DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date

Where `date` is your DATE/DATETIME-formatted column and `table` is your table.
 
Although it doesn't quite work

This is the code

Code:
SELECT *
FROM returns
WHERE DATE_SUB(CURDATE(), INTERVAL -3 DAY) <= date_collection_email
I have a record where the date is 2006-11-19 and it doesn't show up. If I change the -3 to just 3, it shows all records.

Any ideas?

Thanks
Aaron
 
Trying to get ones that are older than 3 days, ie 3 days or more have passed since the date in the field.

Thanks Rob

Aaron
 
Back
Top Bottom