Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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 ,
help~~~
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.