Adjusting date for UTC offset

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
hobocamp
Premium Member
Premium Member
Posts: 98
Joined: Thu Aug 31, 2006 10:04 am

Adjusting date for UTC offset

Post by hobocamp »

I can't seem to find an answer to this in the forums, but I'm sure someone must have run into this issue before.

In an Enterprise job, I need to subtract a given number (the UTC/GMT offset) from a timestamp field, and return the new timestamp.

It doesn't appear to me that any of the built-in functions would do this, so does anyone have any suggestions on how to accomplish it?

Thanks for your help.

Tom
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Generally (world-wide) or only for one particular time zone? Do they have daylight saving time to be taken into consideration?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
hobocamp
Premium Member
Premium Member
Posts: 98
Joined: Thu Aug 31, 2006 10:04 am

Post by hobocamp »

Ray -

It's just for one time zone. In fact the value is provided in the source data that I receive, so I simply have to take that value and subtract that number of hours from the timestamp.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Probably a function like TimestampFromSecondsSince() using 3600 * hours as the offset.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
hobocamp
Premium Member
Premium Member
Posts: 98
Joined: Thu Aug 31, 2006 10:04 am

Post by hobocamp »

Thanks Ray! I tried that function and it provided what I needed. It was a much more elegant solution than what I was coming up with.

Thanks again.

Tom
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

ray.wurlod wrote:Probably a function like TimestampFromSecondsSince() using 3600 * hours as the offset. ...
Ray-

How to pass the number of hours to offset since it will change with day light saving.
Thank you,
Anu
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Since this is a time- (date-) variant quantity, I'd recommend calculating the hours separately from the job and passing it as a job parameter value. Perhaps you could interrogate the TZ environment variable.

Even better would be to have a daylight saving flag in a time dimension table, or in a related table. A great example for a range lookup.
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