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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Difference in times than span midnight

Hey all

Can anyone help with what is probably a fairly simple question to answer.

I need to work out the difference in times that span midnight without them returning a huge negative number.

Time 1 = 23:59:57

Time 2 = 00:00:18

I want the answer 00:00:21 but I'm getting the answer -23:59:39.

Many thanks in advance!

1 Solution

Accepted Solutions
sunny_talwar

May be use timestamp (which includes the date) to find the difference instead of just using the Time? Or this

Interval(If(Time2 - Time1 > 0, Time2-Time1, 1+Time2-Time1), 'hh:mm:ss')

View solution in original post

4 Replies
sunny_talwar

May be use timestamp (which includes the date) to find the difference instead of just using the Time? Or this

Interval(If(Time2 - Time1 > 0, Time2-Time1, 1+Time2-Time1), 'hh:mm:ss')

Anil_Babu_Samineni

This?

Date(If(Time2 - Time1 > 0, Time2-Time1, Avg(1)+Time2-Time1), 'hh:mm:ss')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anil_Babu_Samineni

Sunny, Does Date returns same as Interval ??

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

Perfect! Adding the 1 to the calculation worked perfectly! Thanks!