Page 1 of 1

String toDate conversion

Posted: Fri Oct 02, 2009 1:22 pm
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

Posted: Fri Oct 02, 2009 1:46 pm
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.

Posted: Tue Oct 06, 2009 3:04 pm
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

Posted: Tue Oct 06, 2009 3:09 pm
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.