Today I'm facing with problem, which I can't solve.

I need to check if two datetimes (2019-04-08 13:30:00 - 2019-04-08 15:30:00 ) are between or overlap two others (2019-04-08 14:00:00 - 2019-04-08 16:00).

Imagine that those datetimes are event's date. We can see that there is an event between 14:00 and 16:00 so we cant' have other between.

I've tried something like this:

(('2019-04-08 13:30:00.000' between Start and Stop) OR
('2019-04-08 15:30:00.000' between Start and Stop))

How to check if there is an "event" already ?


To check for overlaps, you only need 2 conditions, the start or interval A with the end of interval B, and vice versa:

      '2019-04-08 13:30:00.000' < Stop 
  AND Start < '2019-04-08 15:30:00.000'
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.