Criteria help in a query

J

JattilaB

I am trying to filter some date fields.

the first one is easy "is not null"
but now what if I would like to match the date field with a given month and
year

do I have to do this with VB or can I do it right off the query design.
 
K

Kevin

Use the Month() function and Year () function. If you want
all records for May 2002 you would use Month(5) and Year
(2002). You can do this in both VBA and in the query
design. To do this in the query, you would need a Month
field that would look something like Month:Month(date
field name). In the criteria you would place 5. Similarly
for the year you would have a year field that would look
something like Year:Year(date field name) and youwould
insert 2002 into the criteria.

Hopt that helps!

Kevin
 
W

Wayne Morgan

It can be done in the query, but you may want to create a calculated field
to do this. The calculated field doesn't need to show in the queries output
(uncheck the Show box).

For the field:
FilterDate:Format([DateField], "mmyyyy")

For the criteria:
[What month are you looking for?] & [What year are you looking for?]

The criteria could also come from a date on a form, just format it to
"mmyyyy" to match the field.
 

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