Criteria based on years

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am needing help with calculating my date criteria in a query.
At the beginning of each year (January), I will need to print a report
extracting data for the whole coming year.

I could have put as a criteria the following:
Between 01/01/07 And 31/12/07

This means that I would need to go and change the year at the beginning of
each year, which is not ideal. Is there a better way to do this?

Many Thanks,
Chris1
 
Try criteria of

Between DateSerial(Year(Date()),1,1) and DateSerial(Year(Date()),12,31)

or one that can be quite a bit slower is to use a calculated field to get
the year of the datefield match that against the year of the current date
Field: Year(YourDateField)
Criteria: Year(Date())



--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Thank you John, It is working a treat!

John Spencer said:
Try criteria of

Between DateSerial(Year(Date()),1,1) and DateSerial(Year(Date()),12,31)

or one that can be quite a bit slower is to use a calculated field to get
the year of the datefield match that against the year of the current date
Field: Year(YourDateField)
Criteria: Year(Date())



--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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

Back
Top