Forum Discussion
DateDiff with a Where Clause
- Sep 11, 2024
Hi,
No matter how you formulate your WHERE statement, the DateDiff function does not have a WHERE part/argument. You therefore need a different approach.
Perhaps a DLookUp with WHERE argument would help you to determine the first comparison value, but that would not be very performant.
For more specific help, we would need a more detailed description.
Servus
Karl
****************
Access Forever News DevCon
Access-Entwickler-Konferenz AEK - 19./20.10. Nürnberg
Hi,
No matter how you formulate your WHERE statement, the DateDiff function does not have a WHERE part/argument. You therefore need a different approach.
Perhaps a DLookUp with WHERE argument would help you to determine the first comparison value, but that would not be very performant.
For more specific help, we would need a more detailed description.
Servus
Karl
****************
Access Forever News DevCon
Access-Entwickler-Konferenz AEK - 19./20.10. Nürnberg
thank you.
I have since then put together bits and pieces from a previous expert's response on a separate question and the following is what I came up with and it seems to give me what I need:
SELECT D1.*, NZ((SELECT MIN(FundingDate)
FROM tblDraws AS D2
WHERE D2.ProjID = D1.ProjID
AND D2.Type = D1.Type
AND D2.FundingDate > D1.FundingDate)-FundingDate,0) AS DayCount
FROM tblDraws AS D1
ORDER BY ProjID, Type, FundingDate;
Nested queries are hard for me to follow but I am getting better at them.
thank you for the response guys.