Extract month from a date field

  • Thread starter Thread starter John Conklin
  • Start date Start date
J

John Conklin

Hello all,

I want to set a date criteria for a query and need some help.

I want the user to enter the month they want the report for and use that to
pull all the records that have a close date that fell in that month.

Any help or suggestions greatly appreciated.

Thanks,
~John
 
You could use DatePart in the criteria row for the date field that you're
querying. I think you would need to ask for the month and the year. The SQL
would be something like:

SELECT YourTable.YourDateField, OtherFields that apply
FROM YourTable
WHERE (((DatePart('m',[YourDateField]))=[Enter Month Number]) AND
((DatePart('yyyy',[YourDateField]))=[Enter Year YYYY]))
 
What do you want: the month number (1, 2, 3, ... 12), or its name?

For the former, use Month([MyDateField]). For the latter, use
Format([MyDateField], "mmm") to get Jan, Feb, Mar, or Format([MyDateField],
"mmmm") to get January, February, March
 

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