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 239 times
1
Community
- 1
- 1
Charles Follet
- 797
- 7
- 27
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
- 12,683
- 5
- 37
- 64
-
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