How to check for overlapping events in a period

Case1: No Event between Period Start Date and Period End Date
Case2: No Event which subsets another event Period Start Date and Period End Date
Case3: No Event which starts before period start date and ends in between some other events end date
Case4: No Event which starts after some other event period start date and ends after events end date

oVERLAPPING eVENT

Where Clause:

SELECT count(event) 
  FROM tblEvent
 WHERE (new_event_start_date BETWEEN old_event_start_date and old_event_end_date OR
        new_event_end_date BETWEEN old_event_start_date and old_event_end_date) OR 
        new_event_start_date <= old_event_start_date OR new_event_end_date >= old_event_start_date

Case1,2,3:

     new_event_start_date BETWEEN old_event_start_date and old_event_end_date OR
     new_event_end_date BETWEEN old_event_start_date and old_event_end_date

Case4:

new_event_start_date <= old_event_start_date OR new_event_end_date >= old_event_start_date

Comments are closed.