0

I'm sending alerts out when a scheduled job has ended. I'm selecting records where end date and time equal NOW(). The script runs every minute via cronjob.

WHERE TIMESTAMP(end_date, end_time) = NOW()

The alerts are not being sent out because the cronjob is running every minute and I'm selecting records based on NOW(), which is to the second. So it's almost impossible that the script is run at the same time a job ends.

Is there anyway I can select records which have an end time within the current minute which the cronjob runs? I want to make sure I'm catching these jobs as soon as they end.

Klav
  • 405
  • 1
  • 9
  • 19
  • 1
    Related: [Rounding a DATETIME value in MySQL to nearest minute](http://stackoverflow.com/q/25747539/2298301) – Dhruv Saxena Apr 20 '17 at 18:19
  • Ahh yes, I could round. I might have to go that route. Right now I'm testing selecting records within the past minute `TIMESTAMP(end_date, end_time) BETWEEN DATE_SUB(NOW() , INTERVAL 1 MINUTE) AND NOW()` – Klav Apr 20 '17 at 18:37

0 Answers0