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

how to calculate duration time from start time and end time columns

Hi,

i have columns like [start time], [end time], so i have to 'spent time'

for eg: data is like below. here total time has to calculate only if [start time]and [finish time] available

Start time Finish time
02:45:23 03:10:15
06:26:00  
12:57:54  
15:09:12 17:40:39
Labels (2)
5 Replies
G3S
Creator III
Creator III

if(not isnull([Start time]) and not isnull([Finish time]),[Finish time]-[Start time]) as spent time

vanir88
Creator
Creator
Author

i used below condition but its throwing error like expected  ")"  can you please correct of anything wrong

if(not IsNull(Timestamp#([Time Finished],'YYYY-MM-DD hh:mm:ss.fff'))- not IsNull(Timestamp#([Time Started],'YYYY-MM-DD hh:mm:ss.fff')), ('YYYY-MM-DD hh:mm:ss.fff')) as Duration

Started Time Finished Time
2023-01-03T02:45:23Z 2023-01-03T02:49:23Z
2023-01-03T06:26:00Z  
2023-01-03T12:57:54Z  
2023-01-03T15:09:12Z 2023-01-03T17:40:57Z

 

G3S
Creator III
Creator III

if(not IsNull([Time Finished]) and not IsNull([Time Started]),

Timestamp#([Time Finished]-[Time Started],'YYYY-MM-DD hh:mm:ss.fff')

,'YYYY-MM-DD hh:mm:ss.fff') as Duration

vanir88
Creator
Creator
Author

it is not coming correctly, if [Time Finished] column is empty it has to show as empty only, and duration format is coming like below. 

the expected result is like for example in the above table the Duration should come as   00:04:00

 

vanir88_0-1677044123214.png

 

G3S
Creator III
Creator III

if(not IsNull([Time Finished]) and not IsNull([Time Started]), ([Time Finished]-[Time Started])) as Duration

if this does not show in the format you require you can add the timestamp expression