Selecting entries by date - >= NOW(), MySQL

前端 未结 6 1063
盖世英雄少女心
盖世英雄少女心 2020-12-13 14:11

I have a Calendar of Events table and I would like to select events with dates equal to or greater than today. When I use the following SELECT statement, it only retrieves e

6条回答
  •  自闭症患者
    2020-12-13 14:38

    Here's the difference between CURDATE and NOW:

    mysql> select CURDATE();
    +------------+
    | CURDATE()  |
    +------------+
    | 2017-03-17 |
    +------------+
    1 row in set (0.03 sec)
    
    mysql> select NOW();
    +---------------------+
    | NOW()               |
    +---------------------+
    | 2017-03-17 09:04:45 |
    +---------------------+
    1 row in set (0.00 sec)
    

    I always use NOW just to be accurate

提交回复
热议问题