Conversion of Timestamp field

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
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Conversion of Timestamp field

Post by DS_SUPPORT »

Hi,

can any one tell us how to covert a timestamp field which contains microseconds in it.

My input is coming as :25-MAY-10 01.19.11.968986 PM

we want Output in the format of 2010-05-25 13:19:11.968986

How to handle micro seconds conversion.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

1. Convert to String.
2. Decompose into components (date, time). Use Field() function.
3. Convert date format. Oconv(Iconv()) with appropriate format strings.
4. Append space and time component (including fractional seconds).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DS_SUPPORT
Premium Member
Premium Member
Posts: 232
Joined: Fri Aug 04, 2006 1:20 am
Location: Bangalore

Post by DS_SUPPORT »

Hi Ray,

For my Target i am using DRS stage,so i am using the meta SQL %DateTimeIn() ,which doesn't handle the microseconds part.

So we tried like %DateTimeIn()%Concat(Microseconds),but we got the error as "ORA-01849: hour must be between 1 and 12"
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

svDatePart::  Oconv(Iconv(Field(InLink.TheTS, " ", 1, 1), "DMY"), "D-YMD[4,2,2]")

Code: Select all

svTimePart:: Oconv(Iconv(Field(Field(InLink.TheTS, " ", 2, 1), ".", 1, 1) : Field(InLink.TheTS, " ", 3, 1), "MT", "MTS")

Code: Select all

svFractionalSeconds::  Field(Field(InLink.TheTS, " ", 2, 1), ".", 2, 1)

Code: Select all

Result::  svDatePart : " " : svTimePart : "." : svFractionalSeconds
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In other words, dump the "meta SQL" and do it all "in job". :wink:
-craig

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