I am trying to query a range within a range. I have a table which has a ProjStartDate and a ProjEndDate field. There is also a DailySalary field. My report has a RptStartDate and a RptEndDate. I am trying to have the report show the salary calculation for any projects with dates within the range of RptStartDate and RptEndDate.
My query is currently set so the start date is StartDate: IIF([RptStartDate]>[ProjStartDate],[RptStartDate],[ProjStartDate]) and the end date is EndDate: IIF ([RptEndDate]<[ProjEndDate],[RptEndDate],[ProjEndDate])
This works well for any projects that have start or end dates that fall withing the report range. What it is failing to pickup is any project that has larger date range than the report date range. (It won't pick up a project with a range of 1/1/05 - 12/31/06 if the report range is 1/1/06 - 6/30/06)
Ultimately what I want is the salary for each project for just the days within the report date ranges. Another user gave me a solution that works in Excel (THANKS GAVONA)...
=IF(AND(ProjStartDate<RptEndDate,ProjEndDate>RptStartDate),MIN(RptEndDate,ProjEndDate)-MAX(RptStartDate,ProjStartDate),0)
This formula will give you the number of days the project has been active within the report period. It is a formula you would put in a cell in the worksheet. Syntax may be different in a query.
...but I'm having a difficult time converting it to work in Access. Would anyone smarter than me help figure this out? Thanks so much!
My query is currently set so the start date is StartDate: IIF([RptStartDate]>[ProjStartDate],[RptStartDate],[ProjStartDate]) and the end date is EndDate: IIF ([RptEndDate]<[ProjEndDate],[RptEndDate],[ProjEndDate])
This works well for any projects that have start or end dates that fall withing the report range. What it is failing to pickup is any project that has larger date range than the report date range. (It won't pick up a project with a range of 1/1/05 - 12/31/06 if the report range is 1/1/06 - 6/30/06)
Ultimately what I want is the salary for each project for just the days within the report date ranges. Another user gave me a solution that works in Excel (THANKS GAVONA)...
=IF(AND(ProjStartDate<RptEndDate,ProjEndDate>RptStartDate),MIN(RptEndDate,ProjEndDate)-MAX(RptStartDate,ProjStartDate),0)
This formula will give you the number of days the project has been active within the report period. It is a formula you would put in a cell in the worksheet. Syntax may be different in a query.
...but I'm having a difficult time converting it to work in Access. Would anyone smarter than me help figure this out? Thanks so much!