Since you've already worked out 31-Mar-2013, just subtract a year from that using nested DateAdd
functions:
=DateAdd("yyyy"
, -1
, DateAdd("d", -1, DateSerial(Year(Now()), Month(Now()), 1)))
This returns 31-Mar-2012.
Domanda
I have to pull some comparative data and want to set the reoport to run automatically.
To get the first date range I use parameters
=DateAdd("m", -3, DateSerial(Year(Now()), Month(Now()), 1))
This is the start date 3 months ago i.e. 1 Jan 2013.
=DateAdd("d", -1, DateSerial(Year(Now()), Month(Now()), 1))
This is the end date, last day of last month is 31 Mar 2013.
I need to get the same dates for last year so I am using
=DateAdd("m", -15, DateSerial(Year(Now()), Month(Now()), 1))
This is the start date 15 months ago ie. 1 Jan 2012
What would I use to find the last day of the month 13 months ago, i.e. 31 Mar 2012?
Soluzione
Since you've already worked out 31-Mar-2013, just subtract a year from that using nested DateAdd
functions:
=DateAdd("yyyy"
, -1
, DateAdd("d", -1, DateSerial(Year(Now()), Month(Now()), 1)))
This returns 31-Mar-2012.