I am trying to figure out if any dates in a table for a particular ID overlap. Here is an example of my table
ID | EffDate | ExpDate
---------------------------------
1 | 2000-01-01 | 2010-12-31
2 | 2000-01-01 | 2050-12-31
1 | 2011-01-01 | 2011-12-31
1 | 2011-12-31 | 2050-12-31
In TableA I need to check to make sure that none of the ID’s intersect with “themselves” so none of the 1’s can intersect with any other one but doesn’t matter if the eff and exp dates intersect with ID 2.
Not looking for a complete answer just a starting point.
Thanks in advance
This finds an overlap between two of your rows with
IDequal to 1:Result:
You can play with the comparison operators to make either or both of
EffDateandExpDateinclusive or exclusive boundary values.