Link to home
Start Free TrialLog in
Avatar of BauwensER
BauwensERFlag for Belgium

asked on

calculate period based on a date (invoice date)

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.
Avatar of Cluskitt
Cluskitt
Flag of Portugal image

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")
Avatar of mbizup
Try this:

Format(DateAdd(YourDate,"m", -1), "mmmm, yyyy")
To also show year, you can use the format with "MMMM, yyyy"
ASKER CERTIFIED SOLUTION
Avatar of Runrigger
Runrigger
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I got the DateAdd arguments backwards in my comment.

The syntax, as the others have is:

DateAdd(Interval, Number,Date)
thank you very much