views:

143

answers:

2

How can I compare the current date of the web server with a date I have stored in the mySQL database and 3 days before that that in the database to send a notification email ?

+1  A: 

This will select rows whose mydate is at least 3 days earlier than the current date:

SELECT  *
FROM    mytable
WHERE   mydate <= SYSDATE() - INTERVAL 3 DAY
Quassnoi
And to automatically send the e-mail can I use a cron-job that executes the script every day ?
`@Prema`: sure you can.
Quassnoi
A: 

You just need to write a program which queries the db and get all email ids which has (now()-3) = field in db you are comparing against and send mail to those email ids and add it as a scheduled task/crontab which will get executed daily(schedule time when web server is less utilized).

Umesh