Filter records on current and previous months

K

KLR

I need to create 2 queries that will pull through all records with the
current month in date field, and another pulling through all records
dated the previous month. I want the query to be automated so the
criteria doesn't have to be amended each month and don't want to use a
parameter query either.

I have tried using DateSerial(Year(Date()),Month(Date()),1) And
<DateSerial(Year(Date()),Month(Date())+1,1) to pull through records for
the current month and was hoping to adapt for previous month but it
isn't working.

Does anyone have any suggestions?

Many thanks.

KLR
 
K

KLR

I have now used the following successfully to filter records on current
month:-

Month([week com])=Month(Now())

But again am having trouble with adapting this for records from the
previous month.
 
R

Rick Brandt

KLR said:
I need to create 2 queries that will pull through all records with the
current month in date field, and another pulling through all records
dated the previous month. I want the query to be automated so the
criteria doesn't have to be amended each month and don't want to use a
parameter query either.

I have tried using DateSerial(Year(Date()),Month(Date()),1) And
<DateSerial(Year(Date()),Month(Date())+1,1) to pull through records
for the current month and was hoping to adapt for previous month but
it isn't working.

Does anyone have any suggestions?

WHERE DateFieldName >= DateSerial(Year(Date()), Month(Date())-1,1)
AND DateFieldName < DateSerial(Year(Date()), Month(Date())+1, 1)
 

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

Top