Solved

calculate period based on a date (invoice date)

Posted on 2012-03-23
6
388 Views
Last Modified: 2012-03-23
I would like to know if there is a function to calculates the month and the year for you based on a date in this format: "mm/dd/yyyy". The month to derive should be the month of the invoice date -1. For example if the invoice date is 01/10/2012 then the period should show: December, 2011. Another example: when the invoice date is 12/12/2011 then period should be November, 2011, etc...

Any help is most appreciated.
0
Comment
Question by:BauwensER
  • 2
  • 2
  • 2
6 Comments
 
LVL 18

Expert Comment

by:Cluskitt
ID: 37757232
If you just want the month, you can use:
Month(Dateadd(month,-1,InvoiceDate))
You can then format it any way you want.
You can also use (in VBA anyway):
Format(Dateadd(month,-1,InvoiceDate),"MMMM")
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37757234
Try this:

Format(DateAdd(YourDate,"m", -1), "mmmm, yyyy")
0
 
LVL 18

Expert Comment

by:Cluskitt
ID: 37757238
To also show year, you can use the format with "MMMM, yyyy"
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 11

Accepted Solution

by:
Runrigger earned 500 total points
ID: 37757243
try something like this;

Format(DateAdd("m",-1,[date]),"Mmmm YYYY")
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37757259
I got the DateAdd arguments backwards in my comment.

The syntax, as the others have is:

DateAdd(Interval, Number,Date)
0
 
LVL 11

Expert Comment

by:Runrigger
ID: 37757276
thank you very much
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question