Date Timezone Conversion

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
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Date Timezone Conversion

Post by thompsonp »

I need to convert several fields (could be characters, timetamps or dates, doesn't really matter) in a row of data from one timezone to another before they are stored in the database. This would need to take account of daylight saving.

I thought that a parallel routine, accessible in the derivation of a transformer, would be a nice place to do this.

Obviously this would need writing in C++ and from a quick look on the web it is non standard but the ICU library and others support it.

Before I go off down this path and get the sys admin person to install the library etc, can anyone suggest a better approach, or has anyone already done something similar that they'd like to share?

Thanks
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

By saying Converting from one timestamp to another, do you mean updating set of records from old file to a new file with a updated timestamp?
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Post by thompsonp »

It doesn't really matter whether the input data is a character, date or timestamp. It represents a date and time and another field gives the timezone for that data.

I need to convert the date time from the supplied timezone to another one.

e.g.

DateTime TZ
200604010200 BST

needs converting to GMT
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

If you search for the same in the forum, you may get some informations like using Basic routine or TZ environmental variable from unix.
The first option may not be usefule for your case, since you need to work out record wise. Perhaps you can try for the second approach.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Post by thompsonp »

The first option (Basic) is not really suitable as I want to use a parallel transformer rather than a Basic transformer.

As far as I am aware the TZ environment variable just shows what timezone the unix account is using (e.g. my dsadm account has it set as GMT0BST) which is irrelevant as each row of data says what timezone it is in and I will have the timezone I want to convert it to as a job parameter.
anujgarg
Participant
Posts: 38
Joined: Sun Jun 26, 2005 11:17 pm

Post by anujgarg »

Can anyone pls explain How to get the current timezone of system using that TZ unix env variables as i am not aware of that.

Pls explain in little detail how to get that in PX job.

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

Post by ray.wurlod »

Set up $TZ as a job parameter. Make its default value $ENV, so that it's picked up from the UNIX environment.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jking123
Premium Member
Premium Member
Posts: 29
Joined: Tue Mar 23, 2004 9:18 pm

Post by jking123 »

I didn't see the answer to this question through searches. Am I assuming correctly that this is currently not possible in Datastage and I will have to write an extternal routine using icu etc and call it thru datasatge.

In general the question is like this:
If my data contains in one row
date1,timezone1,date2,timezone2,date3,timezone3
and I need to convert all the above to GMT
then currently not possible using any built in routine or functionality.
timezones can be any timezone.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Create a Lookup File Set showing, for each time zone, the offset from GMT (or UTC if you're a purist!), the date daylight saving kicks in and the date daylight saving kicks out. Keep this maintained (up to date). Use a Lookup stage to get the offset, and adjust hours accordingly (convert hours to seconds and use TimeSecondsFromTime() or whatever that function is called).
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