Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Duration between two Time fields not dates

Dear team,

I have a table where I have arrival time in one column and left time in another field, i need to know the duration between those two times

I am using qlik sense

the outcome should be in hours but decimal example 2.5 is two hrs and 30 min

thank you in advance.

18 Replies
YoussefBelloum
Champion
Champion

Good, I just recommend using Interval() for this specific need, because it is designed exactly for this type of calculations..

don't forget to close the thread

Anonymous
Not applicable
Author

didn't work for intervals, can you using what i shared, convert it by using intervals so i can check it.

YoussefBelloum
Champion
Champion

yes, but you will need to share a sample app for that I should take YOUR expression with YOUR data to convert it

Anonymous
Not applicable
Author

Thank you here is the sample data,

i have faced an issue, that the left time sometimes is in the next day after 12:00am so the time is negative.

in the sample there is the date as well, so can you create something that will calculate the duration using the date and time,

really appreciate it.

YoussefBelloum
Champion
Champion

here you are

it is working as expected

Anonymous
Not applicable
Author

it is an empty file, couldn't load it, can you paste the code here that you have used?

YoussefBelloum
Champion
Champion

try it again

there is no code, only this expression:

=Interval(Timestamp#([Left Time],'hh:mm')-Timestamp#([Arrival Time],'hh:mm'),'hh:mm')

put your dimensions and use the expression above

Anonymous
Not applicable
Author

it is giving decimal and not working multiplying by 1440

and you didn't react towards the day. as subtracting two times might give negative if in different days.

regards.

YoussefBelloum
Champion
Champion

I wrote something related to the day and I delete it, if you want to include the day, you can do it by concatenating your Day field with your time field inside the Timestamp#() function, like this:

=Interval(Timestamp#([Left Date]&[Left Time],'DD-MM-YYYY hh:mm')-Timestamp#([Arrival Date]&[Arrival Time],'DD-MM-YYYY hh:mm'),'hh:mm')


if this don't solve your problem, take the solution that is working for you


Regards