How check intersection of DateTime periods [duplicate]

If in your program the ranges A1-A2 and B1-B2 are “proper” in the sense that it is known that A1<=A2 and B1<=B2

then your non-intersection test is simply

if(A1>B2 || B1>A2)

Note I have glossed over whether this is > or >=. The proper choice of operator depends on how you have defined your ranges to include or exclude their endpoints; i.e. whether they represent closed, open, or half-open intervals.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)