Query to search by month

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to create a monthly report. My query would ask for the criteria [Enter
A Month] and based on that, display the data for that month. My date field is
in a mm/dd/yyyy format. Is there an easy way to get this done in the query.
 
Found another post that was similar to my situation. Fixed the problem. No
need to respond.
 
Is this what you need?

Month:
Choose(Month([dteYourFieldName]),"January","February","March","April","May","June","July","August","September","October","November","December")

With Like [Select Month] or similar as the Criteria

Natalie said:
Actually, I take that back. The criteria didn't work... :(

Natalie said:
I need to create a monthly report. My query would ask for the criteria [Enter
A Month] and based on that, display the data for that month. My date field is
in a mm/dd/yyyy format. Is there an easy way to get this done in the query.
 
And what about the YEAR?
"Get all sales data for December of all years" is a lot different from
"Get all sales data for December of this Year" which is different from
"Get all sales data for the most recent December".

To get the current year and specified month, you could use.
Field: YourDateField
Criteria: Between DateSerial(Year(Date()), [Enter month NUMBER (1-12)],1)
AND DateSerial(Year(Date()),1+ [Enter month NUMBER (1-12)],0)

To get the value for the specified month (all years in database)
Field: Format([YourDateField],"mmmm")
Criteria: [Enter Full Month Name (January)]
or
Field: Month([YourDateField])
Criteria: [Enter month NUMBER (1-12)]
 
Thanks. That worked.

John Spencer said:
And what about the YEAR?
"Get all sales data for December of all years" is a lot different from
"Get all sales data for December of this Year" which is different from
"Get all sales data for the most recent December".

To get the current year and specified month, you could use.
Field: YourDateField
Criteria: Between DateSerial(Year(Date()), [Enter month NUMBER (1-12)],1)
AND DateSerial(Year(Date()),1+ [Enter month NUMBER (1-12)],0)

To get the value for the specified month (all years in database)
Field: Format([YourDateField],"mmmm")
Criteria: [Enter Full Month Name (January)]
or
Field: Month([YourDateField])
Criteria: [Enter month NUMBER (1-12)]


Natalie said:
I need to create a monthly report. My query would ask for the criteria
[Enter
A Month] and based on that, display the data for that month. My date field
is
in a mm/dd/yyyy format. Is there an easy way to get this done in the
query.
 

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