Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All ,
Can someone please explain me what does the below script does ?
date(MakeDate(year(AddYears(Today(),-2,num(month(Today()))))),'YYYY-MM-DD');
Left(SalesMonth,4) & Right(salesMonth,2) as yearmonth, ???
Thanks in advance
First, This expression won't work because you need 2 parameters of AddYears()/ You can split into different variations
Year(AddYears(Today(), -2)) -- 2015
Num(Month(Today())) -- 8
MakeDate(2015, 😎 -- 2015-8thmonth-Starting date of the month (2015-08-01) Because, My format of date is YYYY-MM-DD
Date() -- Returns as we need
Finally, It creates a date for current month of 2 years back date
It is supposed to create a date value that's the start of this month two years ago. But the expression is not correct since the parentheses don't match up. It should be =date(MakeDate(year(AddYears(Today(),-2)),num(month(Today()))),'YYYY-MM-DD');
This also gives the wanted result, but is easier to read: Date(MonthStart(Today(),-24),'YYYY-MM-DD')
Wild stab in the dark....
get todays date, get the year of this date, subtract 2 years from it, get the month of this date,format the whole thing as yyyy-mm-dd and convert it to a date
First, This expression won't work because you need 2 parameters of AddYears()/ You can split into different variations
Year(AddYears(Today(), -2)) -- 2015
Num(Month(Today())) -- 8
MakeDate(2015, 😎 -- 2015-8thmonth-Starting date of the month (2015-08-01) Because, My format of date is YYYY-MM-DD
Date() -- Returns as we need
Finally, It creates a date for current month of 2 years back date
Do you know all the functions being used in this expression? If yes, knowing also that the expression evaluation would be inside-out (inner function's output would be passed to outer function as parameter) would help you know what it is doing. Else, if you don't understand a specific function, let know or search help.
I believe this way you would learn better.
hi Gysbert
thanks for the reply ...i got it can you please tell me how does this work ?
Left(SalesMonth,4) & Right(salesMonth,2) as yearmonth,
I'm not going to explain every single function. There's an online help where you can find what Left() and Right() do. Have a look at https://help.qlik.com/qlikview