problem in stringtodate 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
shaonli
Participant
Posts: 80
Joined: Tue Nov 28, 2006 6:52 am

problem in stringtodate conversion

Post 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': "
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
shaonli
Participant
Posts: 80
Joined: Tue Nov 28, 2006 6:52 am

Post 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.
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post 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.
shaonli
Participant
Posts: 80
Joined: Tue Nov 28, 2006 6:52 am

Post by shaonli »

Thank you for your suggestion.
Post Reply