Ever wanted to find overlapping date ranges?
For example if you have two date ranges and want to see if they overlap with existing date fields in MOSS.
Here's a picture of what I'm talking about:
Picture 1
Where..
MS = Parameter Month Start Date
ME = Parameter Month End Date
SD = MOSS Field Storing Start Date
ED = MOSS Field Storing End Date
The Picture 1 above produces the following logic:
Picture 2
There are three possible scenarios:
- Overlapping dates on the start
- Overlapping dates in the middle
- Overlapping dates at the end
Here is the code to reproduce this:
The Code:
DateTime startDateToSearchOn; // parameter DateTime endDateToSearchOn; // parameter string startDateFieldName; // existing MOSS Field Internal name string endDateFieldName; // existing MOSS Field Internal name string startDateToSearchOnString = startDateToSearchOn.ToString("s"); string endDateToSearchOnString = endDateToSearchOn.ToString("s") string startDateToSearchOnString = startDateToSearchOn.ToString("s"); |
1 comment:
Couldn't you do the same thing with the following logic:
Find all MOSS Date entries where:
ED > MS & SD < ME
I think that picks up everything.
Thanks!
Post a Comment