Find Intersection of Two Date Ranges

Posted by Tony Buser Tue, 29 Jul 2008 16:23:00 GMT

Say you have a database of events that span multiple days and you want to filter all events between a certain date range. At first I had this giant mess of this AND that OR this AND that... until I found this:

NOT (range1_start > range2_end OR range1_end < range2_start)

That freakin' rules.