Summing Overlapping periods
Posted on 2006-04-03
If I have a list of events:
Now I need to iterate over all the events in myEventList and find any overlapping periods where the sum of attendees is greater than 100. I need to end up with at the minimum, the IDs of the events that cause the sum of the attendees to be greater than 100. An added bonus would be to know the exact date range where that occurs.
1 1/1/2006 12/1/2006 75
2 1/10/2006 2/10/2006 20
3 2/1/2006 6/1/2006 15
4 5/1/2006 10/31/2006 30
5 11/30/2006 1/1/2007 50
6 1/1/2006 1/31/2006 5
So the results I would want generated would be
Events 1,2,3 overlap with a sum of 110 from 2/1/2006 to 2/10/2006
Events 1,3,4 overlap with a sum of 120 from 5/1/2006 to 6/1/2006
Events 1,4 overlap with a sum of 105 from 5/1/2006 to 10/31/2006
Events 1,5 overlap with a sum of 125 from 11/30/2006 to 12/1/2006
If you can't get me the sum or the exact date range that is okay, as long as I have all the event IDs, but as much of that infor as possible is preferred.
Any help with an algorithm to do this is greatly appreciated!!!