Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
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.

Labels (1)
3 Replies
Jason_Michaelides
Partner - Master II
Partner - Master II

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.