Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

2 Months ago (Load Script Variable)

Hello,

I need 3 Variables, i have 2 working,

Which get me the Current Month/Year and the Previous Month/Year and outputs them in full Eg 'January 2012', 'April 2012' etc...

Let Var1 = date(today(),'MMMM') & ' ' & year(today());

Let Var2 = date(monthstart(today())-1,'MMMM') & ' ' & year(today());

Now, I need some help with the 3rd!

As today is May 2012, i need to out 2 months prior in this format 'March 2012'

Any help would be appreciated, thanks.

3 Replies
Jason_Michaelides
Luminary Alumni
Luminary Alumni

Date(MonthStart(AddMonths(Today(),-2)),'MMMM YYYY')

Hope this helps,

Jason

hic
Former Employee
Former Employee

If you really want text values in the variables, then you should use

Let Var1 = Date(MonthStart(Today()),'MMMM YYYY');

Let Var2 = Date(MonthStart(AddMonths(Today(),-1)),'MMMM YYYY');

Let Var3 = Date(MonthStart(AddMonths(Today(),-2)),'MMMM YYYY');

But if you want to use these variables for numerical purposes, e.g. comparisons in where-clauses, then you should use

Let Var1 = Num(MonthStart(Today()));

Let Var2 = Num(MonthStart(AddMonths(Today(),-1)));

Let Var3 = Num(MonthStart(AddMonths(Today(),-2)));

HIC

Not applicable
Author

Henric,

'You Da Man!'

Blockrocker.