Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
In my task i want to load a script which has to create dates. Date should start from 01/01/2012 and end till today. For each date i need to find weekend, year, weekday of a date.
How could i achieve this.Any kind of help is appreciated.
LET vDate = makedate(2012,01,01) ;
Dates:
LOAD Date($(vDate) + iterno()-1) as Date
Autogenerate 1
While $(vDate) + iterno()-1 <= today();
Hi kush141087 ,
Why date is starting from 27-06-1894.
try this
LET vDate = makedate(2012,1,1) ;
Dates:
LOAD Date('$(vDate)' + iterno()-1) as Date
Autogenerate 1
While '$(vDate)' + iterno()-1 <= today();
Or this would be even better with Num around MakeDate()
LET vDate = Num(MakeDate(2012,01,01));
Dates:
LOAD Date($(vDate) + iterno()-1) as Date
Autogenerate 1
While $(vDate) + iterno()-1 <= Today();
Let vStartDate= MakeDate(2011,1,1);
Let vEndDate= Today();
Calender:
LOAD '$(vStartDate)'+IterNo()-1 as Num
AutoGenerate 1
While '$(vStartDate)'+IterNo()-1 <= '$(vEndDate)';
Hi Sunny,
As i am newbie in qliksense,I have some doubths Could you give me reason why,
1.) its better with Num around MakeDate() and what made starting date change from 27-06-1894 to 01-01-2012.
2.) $(vDate) surrounding with ' made starting date change from 27-06-1894 to 01-01-2012 .
Your reasons will be helpful to me to understand better.
Regards,
Supriya
I am not sure why MakeDate() alone was not enough, but it seems that MakeDate() alone saved the date as an expression rather than date. For example, when you sent 01-01-2012 to the Date($(vDate) + iterno()-1) as Date, the vDate was evaluated as 1-1-2012 = -2012 -> 27-06-1894
When we use Num(MakeDate()), then vDate = 40909, which is just a number representation of 01-01-2014. When we used single quotes around our variable vDate we not longer did the math to convert 1-1-2012 = -2012, but we simply used '01-01-2012' which was correctly read as date because of the environmental variable set at the beginning of the script.
All of this is confusing, but to cut the long story short I would always recommend using a date in number format which is easy to convert to date whenever you want using Date() function.
I hope this will be helpful.
Best,
Sunny