SQL between dates including start and end dates

后端 未结 6 860
野性不改
野性不改 2021-01-04 08:34

So I have this:

 (CURDATE() BETWEEN start_date AND end_date) 

Works fine.

But when the CURDATE() is 2011-12-02 and th

6条回答
  •  醉酒成梦
    2021-01-04 09:31

    Since both columns are timestamps, you need to make sure times don't trip you up. To keep the times from tripping you up, cast the timestamps to date.

    where current_date between cast(start_date as date) 
                           and cast(end_date as date);
    

提交回复
热议问题