SELECT MySQL rows where today's date is between two DATE columns

前端 未结 4 1233
粉色の甜心
粉色の甜心 2021-02-05 20:27

How can I get the rows in a table where today\'s date is between (inclusive) two DATE columns of that row? For example, take these two columns of a table:

4条回答
  •  Happy的楠姐
    2021-02-05 20:42

    If you have date (not datetime) columns, use CURTIME() or DATE(NOW()), never NOW() as CesarC correct wrote and you can use BETWEEN.

    SELECT * FROM table WHERE CURTIME() BETWEEN from_date AND to_date

提交回复
热议问题