Check date interval intersection

SELECT * 
FROM tbl 
WHERE existing_start BETWEEN $newStart AND $newEnd 
OR existing_end BETWEEN $newStart AND $newEnd 
OR $newStart BETWEEN existing_start AND existing_end

if (!empty($result))
throw new Exception('We have overlapping')
Last update: Tue, 13 Sep 2022 14:32:15