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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
reporting_neu
Creator III
Creator III

Get Dates between to Dates from one column

Hello,
I have data that only has a start date. There is no end date.

The date is lined up one below the other in one column.

I need the days between each date.

I have:

PersonID ShiftID StartDate
7 2 01.01.2023
7 5 01.07.2024
13 15 01.09.2023
13 19 01.12.2023

 

Example data:

TMP:
Load * Inline [
PersonID, ShiftID, StartDate
7, 2, '01.01.2023',
7, 5, '01.07.2024',
13, 15, '01.09.2023',
13, 19, '01.12.2023'
];

 

I need:

PersonID ShiftID Datefield
7 2 01.01.2023
7 2 02.01.2023
7 2 ...
7 2 30.06.2024
7 5 01.07.2024
7 5 02.07.2024
7 5 today
13 15 01.09.2023
13 15 02.09.2023
13 15 ...
13 19 01.12.2023
13 19 02.12.2023
13 19 today

 

Can you help me please?

Labels (3)
1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

For getting an interval from one date, see 
https://community.qlik.com/t5/Design/Creating-a-Date-Interval-from-a-Single-Date/ba-p/1467840

When you have the interval, you can create all dates between Start and End using a While-loop. See 
https://community.qlik.com/t5/Design/Creating-Reference-Dates-for-Intervals/ba-p/1463944

View solution in original post

3 Replies
hic
Former Employee
Former Employee

For getting an interval from one date, see 
https://community.qlik.com/t5/Design/Creating-a-Date-Interval-from-a-Single-Date/ba-p/1467840

When you have the interval, you can create all dates between Start and End using a While-loop. See 
https://community.qlik.com/t5/Design/Creating-Reference-Dates-for-Intervals/ba-p/1463944

brunobertels
Master
Master

Hi 

try this 

TMP:
Load * Inline [
PersonID, ShiftID, StartDate
7, 2, '01.01.2023',
7, 5, '01.07.2024',
13, 15, '01.09.2023',
13, 19, '01.12.2023'
];


temp:
load
date(date#(StartDate,'DD.MM.YYYY'),'DD/MM/YYYY') as DATE,
PersonID, ShiftID
resident TMP;
drop table TMP;


join(temp)
load PersonID,
date(MinDATE + iterno()-1) as DATE
while MinDATE + iterno()-1 <= MaxDATE;

load PersonID,
if(previous(PersonID)=PersonID,today(),date(max(DATE))) as MaxDATE,
date(min(DATE)) as MinDATE
resident temp group by PersonID;

final:
NoConcatenate
load
PersonID,
DATE,
if(isnull(ShiftID),peek(ShiftID),ShiftID) as ShiftID
resident temp
order by PersonID,DATE;
drop table temp;

 

resulting table sample : 

brunobertels_0-1724314825444.png

 

chek table  for min max Date by shiftId and Person ID 

brunobertels_1-1724314891229.png

 

 

reporting_neu
Creator III
Creator III
Author

Very easy. Thank you!