Converting String to Timestamp 24 hour format

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
harishvardhan
Premium Member
Premium Member
Posts: 14
Joined: Wed Feb 01, 2006 8:50 am
Contact:

Converting String to Timestamp 24 hour format

Post by harishvardhan »

I need to convert "2014/03/21 5:48:26 PM" to timestamp 24 hour format.
the result should be 2014-03-21 17:48:26 can anyone tell me how to do this.
Harish vardhan
dsetlteam
Premium Member
Premium Member
Posts: 35
Joined: Mon Feb 10, 2014 10:14 pm
Location: USA

Post by dsetlteam »

First use convert/ereplace for "/" to "-" conversion,then use StringToTimestamp (In case you are reading from a varchar column) with following setting - %yyyy-%mm-%dd %H:%n:%s %aa
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Are we talking about two strings? They would have to be for this to make sense but wanted to explicitly check.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

If so, then it is two conversions - first a StringToTimestamp using the existing external format (no need to change any delimiters) followed by a TimestampToString using the new desired external format.
-craig

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