Last Month Sales

C

ChuckW

Hi,

Can someone tell me how to do a date restrictor for last
month. I want to get all transaction last month but want
it done on a rolling basis so that when February rolls
around, last month will be January.

Thanks,

Chuck
 
J

JL

Hi Chuck,

Try this.

select ....
from table
where Format([DateField],"YYYYMM") = Format(DateAdd("m", -1, Now()),"YYYYMM")

Hope this helps.
 
J

John Spencer (MVP)

If your Transaction Date Field only stores the date:

Field: TransactionDate
Criteria: Between DateSerial(Year(Date()),Month(Date())-1,1) And DateSerial(Year(Date()),Month(Date()),0)

If your Transaction date has a time in it also then change that slightly.
Criteria: Between DateSerial(Year(Date()),Month(Date())-1,1) And DateSerial(Year(Date()),Month(Date()),1)

The criteria immediately above does have the potential of catching a record that
was entered at exactly Midnight on the first day of 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

Top