user1464296
user1464296

Reputation:

scheduler in mysql to run between hours

I want to create a scheduled mysql query every minute between the hours of 9AM and 11PM.

The syntax I am familiar with is

    DELIMITER $$
CREATE
    EVENT `record_total_points`
    ON SCHEDULE EVERY 1 HOUR STARTS concat(date(now()), ' ', '09:00:00')
    DO BEGIN
            END */$$
                DELIMITER ;

How can I restrict it to run between the hours mentioned above?

Upvotes: 1

Views: 319

Answers (2)

Suresh Kamrushi
Suresh Kamrushi

Reputation: 16086

Just try to add this (Event Scheduler)

DELIMITER $$
CREATE
    EVENT `record_total_points`
EVERY 1 minute STARTS  DATE_FORMAT( NOW( ) ,  "%m-%d-%y 09:00:00" ) ENDS  DATE_FORMAT( NOW( ) ,  "%m-%d-%y 23:00:00" )
DO BEGIN
            END */$$
                DELIMITER ;

Upvotes: 2

scottlimmer
scottlimmer

Reputation: 2268

Couldn't you just add an ENDS statement ON SCHEDULE EVERY 1 HOUR STARTS concat(date(now()), ' ', '09:00:00') ENDS concat(date(now()), ' ', '011:01:00') ?

Upvotes: 0

Related Questions