Query Problem

  • Thread starter Thread starter DavidW
  • Start date Start date
D

DavidW

I am trying to use

Between DateSerial(Year(Date()),Month(Date()),1) And
DateSerial(Year(Date()),Month(Date())+1,0)

to retrieve records for 1 year in a query. This is in the date field
critiria, what I am getting is on the current month,
Any Ideals to what I have done wrong?
David
 
You're getting just the current month's records because that's what the
criteria expression is written to do.

If you want the records for the entire current year, add a calculated field
to the query:
DataYear: Year([DateTimeFieldName])

Put this criterion expression for the DataYear field:
Year(Date())
 
If you want to get records for the coming year (365/366 days) then use:

Between Date()
And DateSerial(Year(Date()) + 1,Month(Date()),Day(Date()))

If you want to select records for the last 365/366 days then use:

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

Adjust the expressions to suit your needs, especially if you store the
non-zero time component.
 

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

Similar Threads


Back
Top