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

Delta time in decimal not working in a load

Hi,

I have some trouble to display a delta time in decimal

I have a table with an ID, a text, and 2 columns date (dateA, DateB)

I want to load this table and calculate the delta time between these 2 dates in decimal hour...

To do so, I made:

Table:

LOAD

     ID,

     concat(text, '/') as "text",

     sum(interval(DateA-DateB, 's') )as "Delta"

Resident Table GROUP BY ID;

My delta is in seconds but I can't convert it into decimal hour... When I try to put / 3600, the result is not as expected.

For example : Delta = 82500s, I should have 22.92 in Delta when I divide by 3600... But when I try to do sum(interval(DateA-DateB, 's') /3600), the result is 0.00265....

Does anyone have an idea ?

Thank you in advance for your reply

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

You should try with

Sum(Num#(Text(interval(DateA-DateB, 's')), '#') /3600)

or

Num#(Text(Interval(Sum(Interval(DateA-DateB, 's')), 'hh')), '#')

View solution in original post

3 Replies
swuehl
MVP
MVP

That's because your Delta is only presenting the seconds in the text representation, while the internal data format is still representing time in fractions of days.

So you need to multiply by 24 instead of dividing by 3600!

edit:

Table:

LOAD

     ID,

     concat(text, '/') as "text",

     sum(DateA-DateB) * 24 as "Delta Hours"

Resident Table GROUP BY ID;

CELAMBARASAN
Partner - Champion
Partner - Champion

You should try with

Sum(Num#(Text(interval(DateA-DateB, 's')), '#') /3600)

or

Num#(Text(Interval(Sum(Interval(DateA-DateB, 's')), 'hh')), '#')

Not applicable
Author

Perfect, thank you !