Timestamp Converstion

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
srini.dw
Premium Member
Premium Member
Posts: 186
Joined: Fri Aug 18, 2006 1:59 am
Location: Chennai

Timestamp Converstion

Post by srini.dw »

Hi,

Please let me know how to convert the following Timestamp to standard Oracle Timestamp format YYYY-MM-DD HH24:MM:SS.

2013-05-28 05:09:03.330000

Is the below correct one.

StringToTimestamp(Ln_Transform.HeadcountDate,"%yyyy-%mm-%dd %hh:%nn:%ss.%6")

Iam getting the below error

Tr_Transform,1: Operator terminated abnormally: Terminating with exception:APT_ParseError: Parsing parameters "%yyyy-%mm-%dd %hh:%nn:%ss.%6" for conversion "timestamp=timestamp_from_ustring[%yyyy-%mm-%dd %hh:%nn:%ss](ustring)": APT_Conversion_String_TimeStamp: Invalid format [%yyyy-%mm-%dd %hh:%nn:%ss.%6] used for string_from_time type conversion


Thanks,
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

First thing to note is your desired format posted does not include microseconds - are you targeting a TIMESTAMP column in Oracle that will support them or are you actually writing to a DATE?

Assuming the former, if you check the documentation you'll see your issue is the format string you are using in the conversion function:

For a timestamp, the format is %yyyy-%mm-%dd %hh:%nn:%ss. If extended to include microseconds, the format is %yyyy-%mm-%dd %hh:%nn:%ss.x, where x gives the number of decimal places seconds is given to.
-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 »

That is, you don't put a "%" in front of the 6. Why not take the leftmost 19 characters of the string and convert that (actually it will already be in the correct format for standard timestamp)?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
srini.dw
Premium Member
Premium Member
Posts: 186
Joined: Fri Aug 18, 2006 1:59 am
Location: Chennai

Post by srini.dw »

Thanks, will try and get back,
Post Reply