Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

billuran
Contributor

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
Valued Contributor

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

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
Contributor

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

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
Honored Contributor III

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

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