String toDate 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
dodda
Premium Member
Premium Member
Posts: 244
Joined: Tue May 29, 2007 11:31 am

String toDate conversion

Post by dodda »

Hello

I am reading String value as varchar from File and i need to convert that string to Date.

My input String =01-MAR-2008
My output should be=01-03-2008

Is there any functions other that StringtoDate.

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So your output is yet-another string or is it actually a Date field? For the former you'd need to combine StringToDate() with DateToString() to get the desired external representation of the date. Only the former is needed for the latter, if that makes sense. Meaning, you only need the StringToDate() function if your target is a Date field.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dodda
Premium Member
Premium Member
Posts: 244
Joined: Tue May 29, 2007 11:31 am

Post by dodda »

Thanks for your reply Chulett.

But the problem is my input String format is DD-MMM-YYYY format. Wondering if this format supports datastage.

inString=12-JUN-2005

I did StringToDate(inString,'dd-%mmm-%yyyy'). The output Date i got was 2005-06-01.

This doesnt match with what i require. Please help me
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You forgot the % in front of the "dd" token, which is why you got the day of 1 for all dates, I'd wager.
-craig

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