Intersects

public static class DateTimeExtensions
{
	public static bool Intersects(this DateTime startDate, DateTime endDate, DateTime intersectingStartDate, DateTime intersectingEndDate)
	{
		return (intersectingEndDate >= startDate && intersectingStartDate <= endDate);
	}
}
Example:
bool eventsInterect = eventXStartDate.Intersects(eventXEndDate, eventYStartDate, eventYEndDate);

Description

Returns true if two date ranges intersect.

Details

Double click on the code to select all.

 

;