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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
n1ef5ng1
Creator
Creator

[Urgent]Scripting error

Hi gurus,

I have two time field, Arrival Time and Expected Arrival Time.

I need to find the difference of this two time,

say expected arrival time is 9am and arrival time is 11am, the output should be -2 (Delay)

expected arrival time is 11am and arrival time is 9an, output should be 2 (early)

However, all my output, whether is it early or delay, do not have negative sign in it. (like absolute value)

any help?

here is my code,

if(LOAD_ATB_DT >TSA_COD ,  ( interval#(timestamp(LOAD_ATB_DT)-timestamp(TSA_COD),'mm')), (interval#(timestamp(LOAD_ATB_DT)-timestamp(TSA_COD),'mm'  )  )   ) as Tranship_Dwell,
if(LOAD_ATB_DT>DISC_ATB_DT, ( interval#(Timestamp(LOAD_ATB_DT) - Timestamp(DISC_ATB_DT),'mm')),(interval#(Timestamp(LOAD_ATB_DT) - Timestamp(DISC_ATB_DT),'mm' ))) as Tight_Connection ,

2 Replies
n1ef5ng1
Creator
Creator
Author

help~~~

tresesco
MVP
MVP

It seems that your if condition is not being used properly. you can simply use the following logic:

If(TIMESTAMP2> TIMESTAMP1,interval( TIMESTAMP2 - TIMESTAMP1, 'hh:mm'),interval(TIMESTAMP1-TIMESTAMP2, 'hh:mm')) as TimeDifference

Thanks.