freightguy
Registered User.
- Local time
- Today, 11:29
- Joined
- Mar 1, 2016
- Messages
- 36
Hi everyone. Need assistance with a query using DATEPART.
When I use the Query builder the query is as such:
Above returns all records with a start date in 2018 and in Q3 - works perfectly.
When I convert that to VBA as follows I get a Expected End Statement Error during compile:
When I get the error it highlights the Q in the DATERPART. I tried QUARTER but that didn't work either. Does VBA use something else rather than Q for Quarter?
thank you
When I use the Query builder the query is as such:
Code:
SELECT tblShipment.expID, tblShipment.SRDate, tblShipment.ProjectNumber
FROM tblShipment
WHERE (((Year([srdate]))=2018) AND ((DatePart("q",[SRDate]))=3));
Above returns all records with a start date in 2018 and in Q3 - works perfectly.
When I convert that to VBA as follows I get a Expected End Statement Error during compile:
Code:
sqlQuery = "Select AVG([MBDBD]-[SRdATE]) as AvgShipDelTime from tblShipment WHERE (((Year([srdate]))=2018) AND ((DatePart("q",[SRDate]))=3))"
When I get the error it highlights the Q in the DATERPART. I tried QUARTER but that didn't work either. Does VBA use something else rather than Q for Quarter?
thank you