MySQL check if two date range overlap with input

前端 未结 4 745
生来不讨喜
生来不讨喜 2021-02-04 20:32

I need to check if two dates over lap with another two dates in my database.

My database looks like this

+----+--------------+------------+------------+
         


        
4条回答
  •  南笙
    南笙 (楼主)
    2021-02-04 21:04

    This is just the where clause. Given InputStartDate and InputEndDate are given by user input, and DataStartDate and DataEndDate are the datetime values in the table:

    where ((DataEndDate > InputStartDate) and (DataStartDate < InputEndDate))
    

提交回复
热议问题