How to check if a date is between date1 and date2 using mysql?

前端 未结 6 2069
醉梦人生
醉梦人生 2021-01-03 03:49

I\'m trying to write a query that will check today\'s date against my table columns date1 and date2 in mysql/php.. This is what I\'m after:

\'events\' table:

6条回答
  •  囚心锁ツ
    2021-01-03 04:30

    SELECT *
    FROM events
    WHERE date1 <= '2012-01-18'
    AND date2 >= '2012-01-18';
    

    This should get you started. You can use DATE(NOW()) to get today's date if you don't want to hardcode a date.

提交回复
热议问题