Query Parameter Question

  • Thread starter Thread starter Todd D. Levy
  • Start date Start date
T

Todd D. Levy

I have a query based report with (among others) has a date field.

I want to setup the criteria for this date field so that when the report
is run it automatically chooses the start date and end date of the
previous month based on the current month that the report is being run
in.

For example, if I run the report today (Aug 3, 2003), the criteria will
automatically run the report from 7/1/03 through 7/31/03 based on July
being the previous month.

Is this possible, and if so how?
 
Todd D. Levy said:
I have a query based report with (among others) has a date field.

I want to setup the criteria for this date field so that when the report
is run it automatically chooses the start date and end date of the
previous month based on the current month that the report is being run
in.

For example, if I run the report today (Aug 3, 2003), the criteria will
automatically run the report from 7/1/03 through 7/31/03 based on July
being the previous month.

Is this possible, and if so how?

WHERE DateFieldName BETWEEN DateSerial(Year(Date()), Month(Date()) - 1, 1) AND
DateSerial(Year(Date()), Month(Date()), 0)
 
Two ways to get the date a year ago are.

DateAdd("yyyy",-1,Date())

or

DateSerial(Year(Date())-1,Month(Date()),Day(Date()))
 
Thanks, Noel
-----Original Message-----
Two ways to get the date a year ago are.

DateAdd("yyyy",-1,Date())

or

DateSerial(Year(Date())-1,Month(Date()),Day(Date()))

.
 
Back
Top