943,816 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 644
  • MySQL RSS
Sep 8th, 2009
0

MySQL Date Problem

Expand Post »
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.

MySQL Syntax (Toggle Plain Text)
  1. "SELECT * FROM quotes WHERE job_status = 'active' AND date_posted is = to 7 days ago";
  2.  
  3. 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.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
dan_ord is offline Offline
30 posts
since Aug 2009
Sep 9th, 2009
0

Re: MySQL Date Problem

The correct query will be

sql Syntax (Toggle Plain Text)
  1. SELECT * FROM quotes WHERE job_status = 'active' AND date_posted<= DATE_SUB(NOW(), INTERVAL 7 DAY)
Reputation Points: 29
Solved Threads: 47
Posting Whiz
mwasif is offline Offline
312 posts
since Dec 2007
Sep 9th, 2009
0

Re: MySQL Date Problem

Thanks, i'll give that a try!
Reputation Points: 10
Solved Threads: 1
Light Poster
dan_ord is offline Offline
30 posts
since Aug 2009
Sep 10th, 2009
0

Re: MySQL Date Problem

That seemed to work fine!

Thanks very much!
Reputation Points: 10
Solved Threads: 1
Light Poster
dan_ord is offline Offline
30 posts
since Aug 2009
Sep 10th, 2009
0

Re: MySQL Date Problem

You are welcome
Reputation Points: 29
Solved Threads: 47
Posting Whiz
mwasif is offline Offline
312 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: which is better MYSQL or MYSQLI?
Next Thread in MySQL Forum Timeline: Multiline Update





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC