Page 1 of 1

how to subtract between two timestamps in datastage server

Posted: Mon Aug 11, 2008 6:36 am
by G.K.K
hai,

we know the way how to subtract between two dates in datastage,but how to subtract between two timestamps..

example:

a) 01-jan-2001 01:30:45:000
b) 04-jan-2001 02:30:45:001

i need to perform a-b & output must be in number of hours. how this could be done in datastage.

it could be great and thankful if anyone help me.....

regards
kk

Posted: Mon Aug 11, 2008 6:42 am
by chulett
Basically the same way but you need to convert the time separately (using "MTS"), add the time to the date then subtract. Lastly, convert the result back to hours.

Posted: Mon Aug 11, 2008 7:34 am
by ArndW
Too add some detail to what Craig has illustrated, you can convert a timestamp into a number of seconds by using

Code: Select all

(ICONV(In.Timestamp[1,11],'D4-DMY[2,3,4]')*24*60*60)+(ICONV(In.Timestamp[13,8],'MTS'))+(In.Timestamp[22,3]/1000)
Do this for the other timestamp, subtract the two values and then multiply the resulting delta in seconds by 60 to get hours.