Need to load "2011-02-02T14:05:35" to Timestamp co

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
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Need to load "2011-02-02T14:05:35" to Timestamp co

Post by mac4rfree85 »

Hi Guys,

My source is a flat file. I have a timestamp column coming as Varchar. THe data is in the format 2011-02-02T14:05:35.

I need to load it to Timestamp Column.

I am using the below transformation in Transformer.

Code: Select all

StringToTimestamp(Link1.Col1,"%YYYY-%MM-%DDT%hh:%mm:%ss")
But i am getting the below error.

Code: Select all

APT_CombinedOperatorController,0: Caught exception from runLocally(): APT_ParseError: Parsing parameters "%yyyy-%mm-%ddT%hh:%mm:%ss" for conversion "timestamp=timestamp_from_ustring[%yyyy-%mm-%dd %hh:%nn:%ss](ustring)": APT_Conversion_String_TimeStamp: Invalid format [%yyyy-%mm-%ddT%hh:%mm:%ss] used for string_from_time type conversion.
I know we can split it to date and time and then concatanate it. But i like to understand why my transformation is failing.

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

Post by chulett »

Because of the 'T' and thus your use of "%DDT" in the mask. Convert it to a space and then convert the timestamp like 'normal'.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Post by mac4rfree85 »

Thanks for your help chulett.

You mean to replace "T" with " " and then convert it to Timestamp. But i gues there is no Replace Function in Parallel job.

Really appreciate your help.

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

Post by chulett »

There is, however, a Convert() function which converts one character with another. Same thing, really.
-craig

"You can never have too many knives" -- Logan Nine Fingers
peddakkagari
Participant
Posts: 26
Joined: Thu Aug 12, 2010 12:07 am

Post by peddakkagari »

Hi,

I think no need to convert any thing you can directly use StringToTimestamp function.
I have used the following function it is working fine

StringToTimestamp('2011-02-02T14:05:35',"%yyyy-%mm-%dd %hh:%nn:%ss")

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

Post by chulett »

That's... interesting. It would seem it doesn't care what comes between the "dd" and "hh" elements. I thought it would be pickier than that. :wink:
-craig

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