Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

YoussefBelloum
Esteemed Contributor

Re: Duration between two Time fields not dates

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

Highlighted
asaadsaleh
New Contributor III

Re: Duration between two Time fields not dates

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

YoussefBelloum
Esteemed Contributor

Re: Duration between two Time fields not dates

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

asaadsaleh
New Contributor III

Re: Duration between two Time fields not dates

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
Esteemed Contributor

Re: Duration between two Time fields not dates

here you are

it is working as expected

asaadsaleh
New Contributor III

Re: Duration between two Time fields not dates

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

YoussefBelloum
Esteemed Contributor

Re: Duration between two Time fields not dates

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

asaadsaleh
New Contributor III

Re: Duration between two Time fields not dates

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
Esteemed Contributor

Re: Duration between two Time fields not dates

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