How to get the current date in MySql?

4

I want to create an event so that every hour verifies that the expiration date of the advertisement is higher than the current date, in which case it should change a topic of this ad in the database, that is, it would be something of the kind that I I tried, but I have questions on how to get the instant date:

    CREATE EVENT e
    ON SCHEDULE EVERY 1 HOUR
    DO UPDATE anuncios SET estado=3 WHERE dataexpiracao > -data actual-
    
asked by anonymous 29.04.2015 / 17:01

2 answers

8

Just use NOW() :

CREATE EVENT e
ON SCHEDULE EVERY 1 HOUR
DO UPDATE anuncios SET estado=3 WHERE dataexpiracao > NOW()
    
29.04.2015 / 17:06
6

Just use the NOW()

Ex:

SELECT NOW()

Return:

  

2015-04-29 12:07:45

Follow the documentation: NOW

    
29.04.2015 / 17:07