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: 
RobertPatrician
Contributor II
Contributor II

Data load script: Create series of dates?

Greetings, I'm hoping to find some help generating a date dimension for my project that isn't reliant on an external file being uploaded. I want it to start with a date of 1/1/1970 in a field, and generate up through 1/1/2050. 

Once I have that in a table, I can resident load it to do the calculations for things like fiscal quarters, fiscal years, and other information. 

What would I put into the load script to generate such a table?

Labels (1)
1 Solution

Accepted Solutions
joseph_morales
Creator III
Creator III

Hi @RobertPatrician ,

You can use the following code to generate the table. I did it using the Autogenerate and While functions.

LET vMinDate =Num('1/1/1970');
LET vMaxDate =Num('1/1/2050');

Dates:
LOAD DATE($(vMinDate) + IterNo() - 1) AS TempDate
AutoGenerate (1)
WHILE $(vMinDate) + IterNo() - 1 <= $(vMaxDate);

Regards

Best Regards,
Joseph Morales

View solution in original post

2 Replies
joseph_morales
Creator III
Creator III

Hi @RobertPatrician ,

You can use the following code to generate the table. I did it using the Autogenerate and While functions.

LET vMinDate =Num('1/1/1970');
LET vMaxDate =Num('1/1/2050');

Dates:
LOAD DATE($(vMinDate) + IterNo() - 1) AS TempDate
AutoGenerate (1)
WHILE $(vMinDate) + IterNo() - 1 <= $(vMaxDate);

Regards

Best Regards,
Joseph Morales
RobertPatrician
Contributor II
Contributor II
Author

Awesome, thank you! This will save a lot of awkwardness with excel files for the date dimension.