Previous Months

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
Hi Ash,
if I've understood your question correctly the answer is:

nmbr_of_mnths_ago=month(now)

HTH Paolo
 
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.
 
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
..
 
Back
Top