How to update a value in a table on a particular time daily?

Discussion in 'PHP' started by krkbkk, Jan 7, 2013.

  1. #1
    I've a table with 2 fields filled :

    moment date Yes NULL
    status int(1) Yes 1

    "moment" is filled with future dates and status is filled with "1"

    I need to check daily by 4:30 PM (IST), the status has to be auto-updated to '2' if "moment"= current date.

    That means, all "moment" values with today's date filled up, the correspding "Status" has to be updated automatically to value "2" EXACTLY by 4:30 PM IST.

    How to do this?

    Thanks in advance.
     
    krkbkk, Jan 7, 2013 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Are you asking for the query, or the method of execution ?

    Anyway, CURDATE() and cron ...

    Something like:
    UPDATE `table` SET `status` = '2' WHERE `moment` = CURDATE() AND `status` = '1';
    Code (markup):
    I can never remember the stupid cron format ... remember to ascertain the timezone being used on the system where cron is executed.
     
    krakjoe, Jan 8, 2013 IP
  3. krkbkk

    krkbkk Well-Known Member

    Messages:
    1,458
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    195
    #3
    Thanks! :)
     
    krkbkk, Jan 9, 2013 IP