How do I limit records to current month

J

James Allen

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?
 
J

JL

Hi James,

Try this.

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

Hope this helps.
 
R

Rick B

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


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




Rick B
 
J

James Allen

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.
 
J

James Allen

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?
 
H

Hong

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?
 
J

John Spencer

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?
 
Top