| | |
MySQL Date Problem
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2009
Posts: 8
Reputation:
Solved Threads: 0
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.
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.
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)
"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.
•
•
Join Date: Dec 2007
Posts: 190
Reputation:
Solved Threads: 25
The correct query will be
sql Syntax (Toggle Plain Text)
SELECT * FROM quotes WHERE job_status = 'active' AND date_posted<= DATE_SUB(NOW(), INTERVAL 7 DAY)
![]() |
Similar Threads
- Mysql: importing .csv file with date. (MySQL)
- mysql Installation Problem (MySQL)
- urgent reply.. mysql bug... about queries date using MySQL (Visual Basic 4 / 5 / 6)
- urgent reply.. mysql bug... about queries date using MySQL (MySQL)
- mysql problem (MySQL)
- Date type problem JSP, mySQL (Java)
- mysql date ALWAYS = 0000-00-00 00:00:00 (PHP)
- Dreamweaver MX2004 & date problem, etc. (Graphics and Multimedia)
- mysql start up problem (MySQL)
Other Threads in the MySQL Forum
- Previous Thread: which is better MYSQL or MYSQLI?
- Next Thread: Multiline Update
| Thread Tools | Search this Thread |
agplv3 amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





