Page 1 of 1

Iconv and Oconv Date Conversion

Posted: Tue Jun 16, 2009 11:55 pm
by tanmaya
Hi,

I have a problem using the iconv and oconv fuctions for the date conversion in Datastage 8.0.1. The format that i entered the date was mm/dd/yyyy and the output desired was yyyy/mm/dd but i got an output of yyyy mm dd.How can i add the slash in my output.

And, i would also like to know how I could convert to date in the form of
yy MON dd.
The fuction that I used is as follows.

Oconv(Iconv(InputFieldName,"D DMY[2,2,4]"),"D YMD[4,2,2]")

Thanks in Advance

Regards,
Tanmaya

Posted: Wed Jun 17, 2009 1:14 am
by ray.wurlod
Welcome aboard. You specified space as the delimiter and that's what you got. What you needed was something like

Code: Select all

Oconv(Iconv(InputFieldName,"DMDY"),"D/YMD[4,2,2]") 
You might find this article informative.

For the second question, try

Code: Select all

Oconv(Iconv(InputFieldName,"DMDY"),"D YMD[2,A3,2]") 

Re: Iconv and Oconv Date Conversion

Posted: Wed Jun 17, 2009 1:28 am
by sachin1
Oconv(Iconv("06/17/2009" ,"D MDY[2,2,4]"),"D/YMD[4,2,2]") gives the output 2009/06/17.

Re: Iconv and Oconv Date Conversion

Posted: Wed Jun 17, 2009 1:38 am
by ray.wurlod
tanmaya wrote:... the output desired was yyyy/mm/dd

Posted: Wed Jun 17, 2009 3:32 am
by tanmaya
ray.wurlod wrote:Welcome aboard. You specified space as the delimiter and that's what you got. What you needed was something like

Code: Select all

Oconv(Iconv(InputFieldName,"DMDY"),"D/YMD[4,2,2]") 
You might find this article informative.

For the second question, try

Code: Select all

Oconv(Iconv(InputFieldName,"DMDY"),"D YMD[2,A3,2]") 

Thank you Ray, that surely worked.

Regards,

Tanmaya

Posted: Wed Jun 17, 2009 6:57 am
by chulett
Then time to mark your topic as Resolved using the button at the top of the page! :wink: