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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
berryandcherry6
Creator III
Creator III

Creation of dates from particular date to till today.

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.

16 Replies
Kushal_Chawda

LET vDate = makedate(2012,01,01) ;

Dates:

LOAD Date($(vDate) + iterno()-1) as Date

Autogenerate 1

While $(vDate) + iterno()-1 <= today();

berryandcherry6
Creator III
Creator III
Author

Hi kush141087 ,

Why date is starting from 27-06-1894.

Kushal_Chawda

try this

LET vDate = makedate(2012,1,1) ;

Dates:

LOAD Date('$(vDate)' + iterno()-1) as Date

Autogenerate 1

While '$(vDate)' + iterno()-1 <= today();

sunny_talwar

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();

lalitinmbd
Partner - Contributor III
Partner - Contributor III

Let vStartDate= MakeDate(2011,1,1);

Let vEndDate= Today();

Calender:

LOAD '$(vStartDate)'+IterNo()-1 as Num

AutoGenerate 1

While '$(vStartDate)'+IterNo()-1 <= '$(vEndDate)';

berryandcherry6
Creator III
Creator III
Author

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

sunny_talwar

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

Capture.PNG

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