Date Range Query MySQL

后端 未结 5 1483
予麋鹿
予麋鹿 2020-12-18 15:09

I need a query to select data between two dates with today\'s date as a reference.

The database has a datetime field for \"start\" and a datetime field for \"end\".<

5条回答
  •  猫巷女王i
    2020-12-18 16:02

    Thank everyone I ended up using:

    select * 
    from news 
    where start = curdate()
    

    I tried

    SELECT * 
    FROM news 
    WHERE NOW() BETWEEN start AND end;
    

    and it worked almost correctly. It didn't want to show news articles that both started and ended on the same day at the same time.

    -tegan

提交回复
热议问题