Previous Months

A

ashg657

Hey guys, right heres the problem...

I need to be able to calculate how many months ago last December was. For
example, if we are in October now, last December was 10 months ago. Next
month (November), December will be 11 months ago. And likewise when we get
around to January 2007, December will be 1 month ago again.

How can I work this out in a query/programming?

Many thanks in advance.
Ash.
 
P

Paolo

Hi Ash,
if I've understood your question correctly the answer is:

nmbr_of_mnths_ago=month(now)

HTH Paolo
 
S

Scott Whetsell, A.S. - WVSP

To calculate the difference between the two months, use datediff as below:

=DateDiff("m", [CurrentMonth], [PreviousMonth])

Replace the fields with the appropriate fields from you database.

Good luck.
 
J

John Spencer

One small modification to take care of December.
Assumption: if you are in December the value you want is zero not 12

Month(Date()) Mod 12

General formula would be like the following

Month(DateAdd("m",-12,Date())) Mod 12

Where you subtract the number of the month you want to find the difference
for. So if you wanted to find the number of months for September
Month(DateAdd("m",-9,Date())) Mod 12

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

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