Page 1 of 1

Problem converting date formats

Posted: Thu Aug 06, 2009 8:30 pm
by yaminids
Friends,

I'm trying to create a new job which parses a Sequential file and populates a staging table.

The problem is with one of the date columns present in the file. The format of the data is "Jul 31 2009" (MM DD YYYY) whereas the DataStage function ICONV expects it in "DD MM YYYY".

How can I convert this format so that I can populate the table

Thanks
Yamini

Posted: Thu Aug 06, 2009 9:16 pm
by chulett
First off, "Jul 31 2009" is not "MM DD YYYY" but rather "MON DD YYYY" and secondly IConv only has expectations if you don't help it so use the appropriate mask to tell it what format the string that needs to be converted is coming in as.

Posted: Thu Aug 06, 2009 10:14 pm
by ray.wurlod
As this article shows, Iconv() is rather agnostic about such niceties. All you need is the order of the components to be right.

Code: Select all

Iconv(InLink.TheDate, "DMDY") 
will convert any date in any legal format in month-day-year order into DataStage internal format (number of days since 1967-12-31).

Posted: Fri Aug 07, 2009 7:23 am
by yaminids
Thanks for the information.
I have modified the job to OCONV(ICONV(dslink3.indate,"DMDY"),"D-YMD[4,2,2]") and it worked

Thanks
Yamini