How do I limit records to current month

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

Guest

I have a date field in my record. How do I write my query to limit my
returns to only records where the date is in the current month?
 
Hi James,

Try this.

Select DateField, .... From Table where Format(DateField, "YYYYMM") =
Format(Now(), "YYYYMM");

Hope this helps.
 
add a new column to your query...
MonthOfRecord: Month([YourDateFieldName])


Then in the criteria, put...
= Month(Date())




Rick B
 
Thanks for the help.
Jim

JL said:
Hi James,

Try this.

Select DateField, .... From Table where Format(DateField, "YYYYMM") =
Format(Now(), "YYYYMM");

Hope this helps.
 
This works great!
Thanks.
Jim

Rick B said:
add a new column to your query...
MonthOfRecord: Month([YourDateFieldName])


Then in the criteria, put...
= Month(Date())




Rick B



James Allen said:
I have a date field in my record. How do I write my query to limit my
returns to only records where the date is in the current month?
 
Hello: Rick

How about if I want to limit records always two month back in the query? for
example: count from the last record back to two month?

Thank you!

Rick B said:
add a new column to your query...
MonthOfRecord: Month([YourDateFieldName])


Then in the criteria, put...
= Month(Date())




Rick B



James Allen said:
I have a date field in my record. How do I write my query to limit my
returns to only records where the date is in the current month?
 
If you want the two months prior to the current month, use this criteria

Between DateSerial(Year(Date()),Month(Date())-2,1) and
DateSerial(Year(Date()),Month(Date()),0)

IF you want records for two months and those two months are dependent on the
Latest date in the field in the table. Replace Date() with
DMax("TheDateField","YourTableName") in the above expression.

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Hong said:
Hello: Rick

How about if I want to limit records always two month back in the query?
for
example: count from the last record back to two month?

Thank you!

Rick B said:
add a new column to your query...
MonthOfRecord: Month([YourDateFieldName])


Then in the criteria, put...
= Month(Date())




Rick B



James Allen said:
I have a date field in my record. How do I write my query to limit my
returns to only records where the date is in the current month?
 

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