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

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

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

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

Post by sam334 »

Craig. Thanks. My membership is still inactive though renewed last week, unlock it for few minutes would be great :)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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]")
Last edited by ray.wurlod on Mon Nov 17, 2014 11:49 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

Post 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.
sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

Post by sam334 »

It worked......Thanks Craig and Ray..
Post Reply