Parameter query for parts of date

R

Rose

My date field is the traditional mm/d/yy format. I need to
create a parameter query that asks for the month and then
the year. I'm sure DatePart comes into this somewhere, but
wild guesses at the right way to word my criteria have failed.
 
D

Douglas J. Steele

Create a couple of calculated fields in your query, one to represent the
month and one for the year. You can either use DatePart, or the Month and
Year functions. Place your parameters relative to those computed fields.

The SQL would look something like:

SELECT Field1, Field2
FROM MyTable
WHERE Month(MyDate) = [Enter Month Number]
AND Year(MyDate) = [Enter Year]
 

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