dkilby
asked on
MS Access Query - current month
I am trying to create a couple of queries in MS Access that when opened show me all the data for the current month, and then another query that shows me all the data for the previous month, without having to enter dates, is this possible and if so how.
The date field is [Date of Call]
Thanks
The date field is [Date of Call]
Thanks
You should never use mmm in SQL as it will fail in a non-English environment.
Use DateSerial.
This month:
Where YourDate Between
DateSerial(Year(Date()), Month(Date(), 1) And
DateSerial(Year(Date()), Month(Date() + 1, 0)
Previous month:
Where YourDate Between
DateSerial(Year(Date()), Month(Date() - 1, 1) And
DateSerial(Year(Date()), Month(Date(), 0)
/gustav
Use DateSerial.
This month:
Where YourDate Between
DateSerial(Year(Date()), Month(Date(), 1) And
DateSerial(Year(Date()), Month(Date() + 1, 0)
Previous month:
Where YourDate Between
DateSerial(Year(Date()), Month(Date() - 1, 1) And
DateSerial(Year(Date()), Month(Date(), 0)
/gustav
Try
... Format ([Date of Call], "yyyy/mm")=Format (Date(), "yyyy/mm") or Format ([Date of Call], "yyyy/mm")=Format (DateAdd("m",-1,Date()), "yyyy/mm")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
FROM Tx
WHERE (((Format([TX_Date],'mmm/y
SELECT Tx.TX_ID, Tx.Cust_ID, Format(DateAdd('m',-1,[TX_
FROM Tx
WHERE (((Format(DateAdd('m',-1,[