Query Parameter Question

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?
 
R

Rick Brandt

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)
 
J

John Spencer (MVP)

Two ways to get the date a year ago are.

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

or

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

Noel

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()))

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top