Overlapping date range MySQL

reyno441

New Member
I have the following data;\[code\]ID startDate endDate-----------------------------------------------1 2010-03-01 10:00:00 2010-03-01 12:00:002 2010-03-01 12:30:00 2010-03-01 15:30:003 2010-03-01 15:30:00 2010-03-01 18:30:00\[/code\]What I want to do is check that a start and end date don't fall inside the startDate and endDate ranges in my data.So for example, the following would be OK;\[code\]startDate endDate-----------------------------------------------2010-03-01 12:00:00 2010-03-01 12:30:002010-03-01 18:30:00 2010-03-01 21:00:00\[/code\]but the following dates would fail, as they would overlap;\[code\]startDate endDate-----------------------------------------------2010-03-01 09:00:00 2010-03-01 13:00:00 (overlaps ID 1)2010-03-01 10:30:00 2010-03-01 11:00:00 (overlaps ID 1)2010-03-01 18:00:00 2010-03-01 19:00:00 (overlaps ID 3)\[/code\]I'm pulling my hair out because I can get one or two of the above 3 test date ranges to fail but not all of them.I am using MySQL.
 
Back
Top