Member Avatar for dan_ord

Hi, I'm using Cron Jobs to set up an automated script which checks for jobs which were posted 7 days ago, which will then delete the record and send the customer out an email.

I've got a bit of knowledge using php and mysql however i'm not sure on how to do the 7 days ago thing.

Below is a very rough bit of code to try explain the process.

"SELECT * FROM quotes WHERE job_status = 'active' AND date_posted is = to 7 days ago";

if num_rows > 0 then execute delete query etc..

Some thing along the lines of that. I know above code incorrect, it's just for demonstration purposes, but if anyone can help me with this it would be greatly appreciated!

Also the time format im using is: 2009-08-24 12:04:55

Cheers Dan.

Recommended Answers

All 4 Replies

The correct query will be

SELECT * FROM quotes WHERE job_status = 'active' AND date_posted<= DATE_SUB(NOW(), INTERVAL 7 DAY)
Member Avatar for dan_ord

Thanks, i'll give that a try!

Member Avatar for dan_ord

That seemed to work fine!

Thanks very much!

You are welcome

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.