I have been writing a small script that would suppose to check the expiration date 30 days prior to that date and send email reminder.
I have a table with column named 'completed' meaning the date whene the course has been finished, completed. Each course is valid for 1 year.
What I have been trying to do is first add one full year to 'completed' then check if that new date falls exactly 30 days prior to now().
Example: the course was finished on 31 Dec 2012. It is valid until 31 Dec 2013, so if TODAY is 1 Dec 2013 email reminder should be sent.
I have this little script:
, completed+INTERVAL 1 YEAR AS expires
WHERE completed > NOW() + INTERVAL 30 DAY
but obviously it doesn't do the job...
Could anyone point me into right direction?
WHERE completed + INTERVAL 1 YEAR < CURRENT_DATE + INTERVAL 30 DAY
Exactly would make it WHERE completed + INTERVAL 1 YEAR = CURRENT_DATE + INTERVAL 30 DAY.