Show previous month

P

Paul.S

I need criteria for a query that will filter out the previous month's records.
Any help would be greatly appreciated.
Paul
 
S

Steve

Let's say the date field in your query is named MyDate. You need to add two
calculated fields to your query. The first looks like:
=Month(MyDate)
and the second looks like:
=Year(MyDate)

Now put the following criteria in the first calculated field:
Month(DateAdd("m",-1,Date)
and put the following criteria in the second calculated field:
Year(DateAdd("m",-1,Date)

Your query will return only the records for the previous month.

If you want all records but the previous month, change your criteria to:
<> Month(DateAdd("m",-1,Date)
<> Year(DateAdd("m",-1,Date)

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
[email protected]
 
J

John W. Vinson

I need criteria for a query that will filter out the previous month's records.
Any help would be greatly appreciated.
Paul

A criterion of
= DateSerial(Year(Date()), Month(Date()) - 1, 1) AND < DateSerial(Year(Date()), Month(Date()), 1)

will do this if applied to a date/time field.

John W. Vinson [MVP]
 
Top