## Thursday, June 5, 2014

### Date Range Overlap

The best way to figure out if two date ranges overlap is explained in this stackoverflow answer. However, there is additional information below on calculating the actual amount of overlap, if any.

1. Only one word Awsome :)

2. Brilliant Explanation :)

3. What's your paypal so I can buy you a case of microbrew? :D

4. Wow. Excellent explanation! Thanks so muuch!

5. You saved my day, thanks!

6. I found that you need only to make a simple calculation:

If (B + D) >= (A + C), then you have overlap. In words, if the sum of the endings if greater of equal to the sum of the beginnings, you have overlap.

But, if you do that four calculations, B-A, D-C, B-C, D-A, you find the size of the overlap by taking the least and if that least is greater than zero. I mean, if the least of the four calculations is zero or negative, automatically you have no overlaps, so you do not need to make that first calculation.

Or

Thank you for your time and interest in this post!
Comments to this blog are sometimes moderated to prevent spam. Please don't be alarmed if your comment does not appear immediately.