convert 'mm/dd/yyyy' to 'yyyy-mm-dd'

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
Shailendra_dstage
Participant
Posts: 4
Joined: Mon Nov 29, 2010 6:05 am

convert 'mm/dd/yyyy' to 'yyyy-mm-dd'

Post by Shailendra_dstage »

my input is '1/19/2011' i am reading as varchar. I need to convert it to '2010-01-19'
Vidyut
Participant
Posts: 24
Joined: Wed Oct 13, 2010 12:45 am

Post by Vidyut »

Use the function: StringToDate(INPUTCOLUMN,"%mm/%dd/%yyyy")
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

Describe scenario clearly by stating what is your target, what is your target datatype and other stuff.

Try with below derivation.

DateToString(StringToDate(INPUTCOLUMN,"%mm/%dd/%yyyy"),"%yyyy-%mm-%dd")
Cheers
Ravi K
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Neither of which will work with a single digit month or day. As requested, let us know your what your target is - another string or is it a Date? Answer will change for the latter.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Jamesliu
Participant
Posts: 3
Joined: Mon Mar 15, 2010 6:18 pm

Re: convert 'mm/dd/yyyy' to 'yyyy-mm-dd'

Post by Jamesliu »

Shailendra_dstage wrote:my input is '1/19/2011' i am reading as varchar. I need to convert it to '2010-01-19'
define your input column as Date, length 10 bytes. Set date_format='%(m,s)/%(d,s)/%yyyy', so DS will convert it to the default format is "%yyyy-%mm-%dd.
Post Reply