Solved

calculate period based on a date (invoice date)

Posted on 2012-03-23
6
375 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now