Varchar to Timestamp 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
Harini
Premium Member
Premium Member
Posts: 80
Joined: Tue Mar 16, 2010 1:32 am

Varchar to Timestamp Conversion

Post by Harini »

Hello All,

Below is a varchar and i need to convert it to timestamp length 23, scale 3..

2009-01-15T00:08:13.109.

I used the below code and it doesnt work...

StringToTimestamp(DSLink316.DATE,"%yyyy-%mm-%dd %hh:%nn:%ss")

Any idea on the right code??

Thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

StringToTimestamp(DSLink316.DATE[1,10]:' ':DSLink316.DATE[12,12],"%yyyy-%mm-%dd %hh:%nn:%ss.3")
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In other words, by skipping the 'T' separator. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Harini
Premium Member
Premium Member
Posts: 80
Joined: Tue Mar 16, 2010 1:32 am

Post by Harini »

ArndW wrote:StringToTimestamp(DSLink316.DATE[1,10]:' ':DSLink316.DATE[12,12],"%yyyy-%mm-%dd %hh:%nn:%ss.3") ...
Thanks, that worked ! :)
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Craig - you gave away the secret 8)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

D'oh! :cry:
-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 »

Just curious (and unable to check at the moment) - can you include the literal T in the format string? That would yield a simpler and self-documented solution.
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