I'm trying to write a dynamic query to retrieve records entered into a table during the previous month, e.g. between 2/1/2018 and 2/28/2018. I'm having a little trouble getting the datediff and dateadd functions to work as expected.
Code:
select DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE())-1, 0)
select DATEADD(MONTH, DATEDIFF(MONTH, -1, GETDATE())-1, -1)
The above statements return the first day and last day of the previous month respectively, 2/1/2018 and 2/28/2018, in SQL Server.
Code:
select DATEADD("M", DATEDIFF("M", 0, DATE())-1, 0)
select DATEADD("M", DATEDIFF("M", -1, DATE())-1, -1)
So, why don't the above statements return do the same in Access 2010? Instead both statements return 2/28/2018.
Thanks for the help.