Page 1 of 1

problem in stringtodate conversion

Posted: Wed Jan 02, 2008 2:54 am
by shaonli
In source there is a char field with this format yyyy-mm-dd.I need to convert this into date with this "mm/dd/yy" format.
I am using the function Stringtodate(input_col,"%mm/%dd/%yy").
The job is getting aborted with the error "Data string '1972-09-' does not match format '%mm/%dd/%yy': "

Posted: Wed Jan 02, 2008 3:04 am
by ray.wurlod
You misunderstand. If you need to convert a string to a date, then you specify the date format of the string (not of the desired date).

Indeed, you never specify the format of a date - a date is a binary data type in DataStage parallel jobs.

So ask yourself, do you want a date coming out of this, or a string in some particular format? Once you have that answer, please post again.

Posted: Wed Jan 02, 2008 3:10 am
by shaonli
Thank u.Now after giving it as Stringtodate(input_col,"%yyyy-%mm-%dd") the job is running fine.It is converting it in the format yyyy-mm-dd.
But i want to convert it into mm/dd/yy.How can i do this please suggest.

Posted: Wed Jan 02, 2008 3:15 am
by Maveric
You can only do it if the target is Char or VarChar. In a transformer use substring to format the output. A derivation like

Code: Select all

In.DateCol[6,2] : "/" : In.DateCol[9,2] : "/" : In.DateCol[3,2] 
should work.

Posted: Wed Jan 02, 2008 3:38 am
by shaonli
Thank you for your suggestion.