My question is the same as Algorithm to detect overlapping periods.
But in my case, a period can be unbouded (No End Date, ie. NULL).
I can't find an elegant way do to that.
Asked
Active
Viewed 263 times
1

Community
- 1
- 1

Charles Follet
- 827
- 1
- 10
- 28
1 Answers
2
For unbounded end dates, you could also do something like:
a.end = a.end == NULL ? MAXDATE : a.end;
b.end = b.end == NULL ? MAXDATE : b.end;
bool overlap = a.start < b.end && b.start < a.end;
Or this could work:
bool overlap = (a.start < b.end || b.end == NULL) && (b.start < a.end || a.end == NULL);

But I'm Not A Wrapper Class
- 13,614
- 6
- 43
- 65
-
Nice ! I did the first solution didn't find it really clean. I accept the second one. Thank you – Charles Follet Feb 10 '16 at 07:59