Solved

calculate period based on a date (invoice date)

Posted on 2012-03-23
6
405 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Familiarize people with the process of utilizing SQL Server views 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 Access…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

742 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