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: 
billuran
Partner - Creator
Partner - Creator

Generate dates every 14 days from a defined min and max date

Hello, I am sure this is pretty easy, but I want to create a table in the script and have it list dates every 14 days from a min date found in table A to the Max Date table A.

Thanks,

3 Replies
aarkay29
Specialist
Specialist

Something Like This

Change vLastDate logic based on your requirement

Let vlastDate='05/26/2017';

If Today()-'$(vlastDate)'=14 Then

Table:

Load * inline [

Date

5/03/2017

6/28/2017

];

NoConcatenate

Table2:

Load

Max(Date) as Max_Date,

Min(Date)  as Min_Date

Resident Table;

LET vStartDate  = num(Peek('Min_Date'));

LET vEndDate   = num(Peek('Max_Date'));

Drop Tables Table,Table2;

TempCalendar:

LOAD

  $(vStartDate) + RowNo() - 1       AS Num,

  date($(vStartDate) + RowNo() - 1) AS TempDate

AUTOGENERATE

  $(vEndDate) - $(vStartDate) + 1;

 

Else

EXIT Script;

billuran
Partner - Creator
Partner - Creator
Author

AAR, thank you for this and actually very accurate based on my title, but I want to generate dates in 14 day increments, IE Jan 1 Jan15 Jan 29 etc...

antoniotiman
Master III
Master III

Hi Bill

Table:
LOAD * Inline [
MinDate,MaxDate
01/01/2016,01/06/2016
01/01/2017,01/06/2017 ]
;
Date:
LOAD (MinDate + (IterNo()-1)*14) as Date
Resident Table
While (MinDate + (IterNo()-1)*14) <= MaxDate
;

Regards,

Antonio