Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
alex_bernea
Contributor
Contributor

Intervals between timestamps in hours with fractions of a day for interval ends

Hello,

I am trying to break the interval between 2 timestamps in order to find out the difference in hours per day with fractions for intervals

I have the following input data:

StartTimeEndTime
02/08/17 20:4402/10/17 04:52

I would like to show them as:

StartTimeEndTimeTime elapsed
02/08/17 20:4402/09/17 00:0003:16
02/09/17 00:0002/10/17 00:0024:00
02/10/17 00:0002/10/17 04:5204:52

I tried while loops and intervals, but I can't find a way to break correctly the edges of the intervals (those that are not full day)

Thank you,

Alex

1 Solution

Accepted Solutions
sunny_talwar

Try this

Table:

LOAD *,

  Interval(EndTime - StartTime, 'hh:mm') as [Time Elapsed];

LOAD TimeStamp(RangeMax(DayStart(StartTime + IterNo()-1), StartTime)) as StartTime,

  TimeStamp(RangeMin(DayStart(StartTime + IterNo()-1, 1), EndTime)) as EndTime

While Floor(StartTime) + IterNo() <= Floor(EndTime + 1);

LOAD * INLINE [

    StartTime, EndTime

    02/08/17 20:44, 02/10/17 04:52

    03/08/17 10:44, 03/10/17 17:52

];

View solution in original post

3 Replies
Anonymous
Not applicable

Try sing interval function explained here.

something like interval(Endtime-StartTime,'HH:MM')

sunny_talwar

Try this

Table:

LOAD *,

  Interval(EndTime - StartTime, 'hh:mm') as [Time Elapsed];

LOAD TimeStamp(RangeMax(DayStart(StartTime + IterNo()-1), StartTime)) as StartTime,

  TimeStamp(RangeMin(DayStart(StartTime + IterNo()-1, 1), EndTime)) as EndTime

While Floor(StartTime) + IterNo() <= Floor(EndTime + 1);

LOAD * INLINE [

    StartTime, EndTime

    02/08/17 20:44, 02/10/17 04:52

    03/08/17 10:44, 03/10/17 17:52

];

alex_bernea
Contributor
Contributor
Author

It works. Thannk you