sven2
10-27-2009, 07:34 AM
Hello,
can somebody help me with the following problem:
given two date ranges, each with start and end dates, how do you determine if the ranges overlap and calculate the number of weeks in these overlap in a query?
For example:
Time to develop a paperbox:
startdate 1/10/2009
enddate 30/10/2009
The filter:
startdate 15/9/2009
enddate 15/10/2009
So the overlap is from 1/10 until 15/10/2009 (2 weeks) ...
How can I make this in a query?
Thanks in advance,
Sven.
namliam
10-27-2009, 08:10 AM
FilterEndate >= DevelopStartDate ??
Try looking into the datediff function to find the period to overlap?
pbaldy
10-27-2009, 08:28 AM
FilterEndate >= DevelopStartDate ??
Actually you have to test that plus that the FilterStartDate <= DevelopEndDate. Filter start/end dates in November would meet that test, but don't actually overlap.
sven2
10-27-2009, 08:32 AM
Hello,
can I solve this with the datediff function?
It is so that the datediff function calculate the time between 2 dates ... but how can I make it so that is take into account the overlap time in weeks?
Best regards,
Sven.
pbaldy
10-27-2009, 12:48 PM
I was bored and had started this before, so:
http://www.baldyweb.com/OverLap.htm
I suspect you could use DateDiff, but you'd have to account for the different possibilities of overlap. I have to take off, but I'll try to ponder it later if the MailMan or somebody else hasn't sorted it out.
namliam
10-28-2009, 03:20 AM
Datediff > Read the help, tells you more and better than I would here.
DCrake
10-28-2009, 03:33 AM
From what you state you can have the following
Overlaps prior to filter start date
Overlaps after filter end date
Overlaps either side of the filter range
No overlap date are same
Then if your date range is samller than the start stop range you can have
Gap between Start date and filter start date
Gap between End date and filter end date
Gaps either side of the start and stop date
So there are a possible 7 variations.
David