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: July 4th at 11:32am