Page 1 of 1

Date Conversion (YYYY-MM-DD to MM-DD-YYYY)

Posted: Mon Nov 17, 2014 10:09 pm
by sam334
All,
Need a help in date conversion. I searched quite a bit but could not find the specific conversion function.

My input is from DB2 and data type is DATE which is YYYY-MM-DD for format. The output is in sequential file (.txt) and it needs to be MM/DD/YYYY format.

I used the below function, but not working.

Oconv(Iconv(As_Of_Dt,"D-MDY[2,2,4]","D/MDY[2,2,4]")

Any help.

Thanks.

Posted: Mon Nov 17, 2014 10:31 pm
by chulett
Hopefully your target field is a string. True DATE data types are just an internal number and thus have no format so I do believe you can skip the IConv and try it with the OConv alone. Either that or leverage whatever DB2 uses for a "to char" function directly in the source SQL.

Posted: Mon Nov 17, 2014 10:39 pm
by sam334
Craig. Thanks. My membership is still inactive though renewed last week, unlock it for few minutes would be great :)

Posted: Mon Nov 17, 2014 10:58 pm
by ray.wurlod
If the source is in YMD order, then your Iconv() function must also specify YMD order. Yours specifies MDY order.

Try

Code: Select all

Oconv(Iconv(InLink.TheDate, "DYMD"), "D/MDY[2,2,4]")

Posted: Mon Nov 17, 2014 11:02 pm
by ray.wurlod

Posted: Mon Nov 17, 2014 11:07 pm
by sam334
Ray, Thanks. as I posted earlier. My premium membership got expired and already renew in process. Can't see the code. Unlocking the code for a while would be really helpful.

Posted: Mon Nov 17, 2014 11:39 pm
by sam334
It worked......Thanks Craig and Ray..