Date Criterion

D

DavidW

I have got a table that has a field that is a date stamp for when a record
is entered. I am trying to sort in a query by the current month and year
only, how do you specify the criterion for that?
 
D

Douglas J. Steele

Create 2 calculated fields along the lines of Month([DateField]) and
Year([DateField]) and set the criteria for them to Month(Date()) and
Year(Date()) respectively.

Alternatively, set the criteria for your DateField to Between
DateSerial(Year(Date()), Month(Date()), 1) And DateSerial(Year(Date()),
Month(Date()) + 1, 0)

If DateField has time in it as well, you'll want to change the end criteria
to DateSerial(Year(Date()), Month(Date()) + 1, 1)
 
D

DavidW

Thanks Doug That Worked!
Douglas J. Steele said:
Create 2 calculated fields along the lines of Month([DateField]) and
Year([DateField]) and set the criteria for them to Month(Date()) and
Year(Date()) respectively.

Alternatively, set the criteria for your DateField to Between
DateSerial(Year(Date()), Month(Date()), 1) And DateSerial(Year(Date()),
Month(Date()) + 1, 0)

If DateField has time in it as well, you'll want to change the end criteria
to DateSerial(Year(Date()), Month(Date()) + 1, 1)

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)



DavidW said:
I have got a table that has a field that is a date stamp for when a record
is entered. I am trying to sort in a query by the current month and year
only, how do you specify the criterion for that?
 

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