I often find myself writing logic to compare two date ranges to see if they overlap. In fact, I’ve done this enough times that I thought it was worth capturing in a blog post to save myself the time of having to figure it out next time. Hopefully you, dear reader, will also find it useful. TL;DR If you don’t need to understand the reason why, no need to read on. Just use this logic:
1 |
(StartA <= EndB) and (StartB <= EndA) |
1 |
StartA > EndB |
Continue reading...