How to read timestamp in "2004-01-01 12:12:12.112"

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
akash_nitj
Participant
Posts: 27
Joined: Fri Aug 13, 2004 3:36 am
Location: INDIA

How to read timestamp in "2004-01-01 12:12:12.112"

Post by akash_nitj »

Hi
How can i read the timestamp in the following format in Parallel job .

Format of timestamp is "2004-01-01 12:12:12.112"


TIA
Akash[/b]
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Akash,

if you want to convert this string into a DS internal format then split it into 3 distinct values: Date, Time and Milliseconds

Say "X" is your string "2004-01-01 12:12:12.112",

Then DateVal = ICONV(FIELD(X," ",1),"D4YMD")
TimeVal = ICONV(FIELD(FIELD(X," ",2),".",1),"MTS")
MilliVal = FIELD(X,".",2)

The internal time representation is in integer seconds since midnight and the ICONV and OCONV time conversions will strip out the milliseconds, so you have to add them manually (ICONV'ing a timestring with decimal digits will cause the function to round up by one second).
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Arnd's advice only works in the BASIC Transformer stage. If you are using the regular parallel Transformer stage, the answer will depend on where you're reading the timestamp from. If it's a text file you can decompose it using substring techniques. If it's from a database you may also need to perform some kind of CAST operation.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

ray.wurlod wrote:Arnd's advice only works in the BASIC Transformer stage...
Oops - just noticed that I responded in the incorrect sub-forum :(
T42
Participant
Posts: 499
Joined: Thu Nov 11, 2004 6:45 pm

Post by T42 »

You could read in microseconds for timestamps in PX. You just need to enable the option within your column definition. (Sql Type needs to be Timestamp, and Extended needs to be Microsecond)
venkateshkumarg
Premium Member
Premium Member
Posts: 10
Joined: Wed Dec 15, 2004 2:19 am

Post by venkateshkumarg »

Hi,
recently we posted some work around...search for Err insert timestamp value (with Microseconds) into Oracle9i
Venkatesh
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or just post a direct link to the thread in question. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply