Page 1 of 1

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

Posted: Fri Feb 18, 2011 5:20 am
by Shailendra_dstage
my input is '1/19/2011' i am reading as varchar. I need to convert it to '2010-01-19'

Posted: Fri Feb 18, 2011 6:30 am
by Vidyut
Use the function: StringToDate(INPUTCOLUMN,"%mm/%dd/%yyyy")

Posted: Fri Feb 18, 2011 7:27 am
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")

Posted: Fri Feb 18, 2011 7:34 am
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.

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

Posted: Fri Feb 18, 2011 3:19 pm
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.