how to subtract between two timestamps in datastage server

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
G.K.K
Participant
Posts: 61
Joined: Tue May 13, 2008 6:54 am

how to subtract between two timestamps in datastage server

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
Post Reply