Query

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I am trying to create a query that will give last years
sales based on the same date last year as to this date
this year. Example Show me last years sales between
1/1/02 & Date()-365. I am trying not to have to change
the queary date range each time. I hope I am being clear.
 
Brian,

Rather than "hard-wire" a specific date into the query criteria, you
can use a Parameter Query, and thus you will be prompted to enter the
period ending date each time. Also, -365 from a date is not ideal way
to go back a year... use the DateAdd function instead. So, in the
query criteria you can put something like...
Between DateAdd("yyyy",-1,[year ending])+1 And [year ending]

Another, possibly preferable approach, is to use an unbound textbox on
a form, where you can enter the year ending date, and then reference
this in the query criteria, such as...
Between DateAdd("yyyy",-1,[Forms]![NameOfForm]![NameOfTextbox])+1 And
[Forms]![NameOfForm]![NameOfTextbox]

I was not clear from your question, but if what you really want is the
date from today, then you can use this criteria.
Between DateAdd("yyyy",-1,Date()) And Date()-1

- Steve Schapel, Microsoft Access MVP
 
Back
Top