oldteddybear
Registered User.
- Local time
- Yesterday, 23:25
- Joined
- Apr 1, 2012
- Messages
- 12
I have two entry fields in a Table defining the ServiceStartDate and ServiceEndDate of times clients enter and leave a service. Similar to this example:
ServiceStartDate ServiceEndDate
22/12/2011 22/01/2012
22/01/2012 24/01/2012
24/01/2012 09/03/2012
09/03/2012 11/03/2012
11/03/2012 30/03/2012
30/03/2012 02/04/2012
02/04/2012
I need a query that identifies all usages between two given dates. My problem is that I cannot get my formula to pick up period within the range when the start or finish date is outside the Query Start Date. It also needs to identify those periods within the range that end after the Query End Date for which no ServiceEndDate has yet been set. This is my calculation to date and I need help please
SELECT T_Placements.ServiceStartDate, T_Placements.ServiceEndDate
FROM T_Placements
GROUP BY T_Placements.ServiceStartDate, T_Placements.ServiceEndDate
[FONT="]HAVING (((T_Placements.ServiceStartDate)=IIf(([ServiceStartDate]<[Start Date]) And ([ServiceEndDate]>[Start Date]),[Start Date])) AND ((T_Placements.ServiceEndDate)=(IIf(([ServiceEndDate])>=[End Date],[End Date],[ServiceEndDate])) And (T_Placements.ServiceEndDate)=IIf("Nz[serviceEndDate]]",[End Date]))) OR (((T_Placements.ServiceStartDate)=IIf([ServiceStartDate]>=[Start Date],[ServiceStartDate])));[/FONT]
ServiceStartDate ServiceEndDate
22/12/2011 22/01/2012
22/01/2012 24/01/2012
24/01/2012 09/03/2012
09/03/2012 11/03/2012
11/03/2012 30/03/2012
30/03/2012 02/04/2012
02/04/2012
I need a query that identifies all usages between two given dates. My problem is that I cannot get my formula to pick up period within the range when the start or finish date is outside the Query Start Date. It also needs to identify those periods within the range that end after the Query End Date for which no ServiceEndDate has yet been set. This is my calculation to date and I need help please
SELECT T_Placements.ServiceStartDate, T_Placements.ServiceEndDate
FROM T_Placements
GROUP BY T_Placements.ServiceStartDate, T_Placements.ServiceEndDate
[FONT="]HAVING (((T_Placements.ServiceStartDate)=IIf(([ServiceStartDate]<[Start Date]) And ([ServiceEndDate]>[Start Date]),[Start Date])) AND ((T_Placements.ServiceEndDate)=(IIf(([ServiceEndDate])>=[End Date],[End Date],[ServiceEndDate])) And (T_Placements.ServiceEndDate)=IIf("Nz[serviceEndDate]]",[End Date]))) OR (((T_Placements.ServiceStartDate)=IIf([ServiceStartDate]>=[Start Date],[ServiceStartDate])));[/FONT]
Last edited: