Hello i have two columns: duration (int) and dateCol (date) in a table.
How should i proceed if i want to know when CURDATE() – dateCol will iqual to duration.
ie: CURDATE() – dateCol (2010-05-08) = duration (14 days), and then send an e-amil?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To do what you want you can use
DATEDIFF:An alternative method is to interval subtraction:
The second can be faster if there is a suitable index.
Note that I’ve chosen to use an inequality test instead of an equality because this will handle missed emails if your process is offline for one day and is restarted the next day. You should mark the row as handled when you’ve handled it to prevent more than one email being sent. This will also prevent multiple emails being sent if your process runs more than once per day (this could happen if you restart it to upgrade / bug fix).