To susbtract hours from DATETIME field

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
dbdecoy
Premium Member
Premium Member
Posts: 17
Joined: Tue Jul 15, 2008 1:17 pm
Location: Hyderabad

To susbtract hours from DATETIME field

Post by dbdecoy »

Hi All

Can any one help with the command for subtracting hours from a date time field in uservariable activity stage.

For eg if I have a input value as 2015-09-21 10:00:00, need to subtract 2 hrs from it and need o/p like 2015-09-21 08:00:00

I think Iconv/oconv function will work.If any one knows please post the syntax for the same
vamsi_4a6
Participant
Posts: 95
Joined: Wed Jun 04, 2014 12:06 am

Post by vamsi_4a6 »

I think TimestampOffsetByComponents function should work
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Only in a Parallel job, this is a Sequence job question.

Yes, you could use them in a custom routine but it would be a little tricky as the date and time portions would have to be handled separately. I.E. separate them and then subtract two hours (7200 seconds) from the time portion. If it rolls below zero (midnight) sutract one day from the date and adjust the time accordingly. Now, I may be misremembering the behaviour when you roll a time back past midnight, you'd need to test that yourself - you may just need the "delete one day" part in that case.

Ray, is your website not up? Moved? Gone? Was going to point them to your routines since you've already done all this but it seems to be down. :(
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Send me an email I'll send you a DSX. Website is under redevelopment in my copious free time (yeah.).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply