Page 1 of 1

Date conversion from mm/dd/yy to CCYY-MM-DD

Posted: Wed Sep 07, 2005 1:20 pm
by Titto
How to convert input MM/DD/YY date value (char) to CCYY-MM-DD (Date type) of target table.

I am using

Code: Select all

 ICONV (READ.DATE, "D-YMD[4,2,2]")
but it is not converting.

Any help appriciated!

Posted: Wed Sep 07, 2005 1:41 pm
by hrthomson
There may be an easier way, but the following works:

OCONV(DateIconv(READ.DATE),"D-YMD[4,2,2]")


DateIconv routine should be included in DS.

I hope it helps!

Heather

Posted: Wed Sep 07, 2005 1:49 pm
by Titto
Hi Heather,
where do i get DateIconv ? is it a routine?

Thanks

Posted: Wed Sep 07, 2005 2:07 pm
by chulett
Converting dates from one output format to another requires two steps - first into internal format and then back out in the desired external format:

Code: Select all

OCONV(ICONV(READ.DATE, "D/MDY"), "D-YMD[4,2,2]")
You only took the first input step - but you used the date mask needed for the output step.

DateIconv must be a custom Heather routine or transform. :wink:

Posted: Wed Sep 07, 2005 2:10 pm
by pnchowdary
Hi Titto,

You can use the below transformation and tell me whether it works for you.

Code: Select all

Oconv(Iconv(Read.Date,"D2/"),"D-YMD[4,2,2]") 
Heather,

As far as I know, there is no standard function in Datastage called DateIconv, if it is, please let me know where I can find it. I am assuming that it might be some custom transform that you guys wrote yourself.

Posted: Wed Sep 07, 2005 2:33 pm
by Titto
Thanks all it worked out!!
as per Craig and Chowdary advice..

Posted: Wed Sep 07, 2005 7:10 pm
by hrthomson
Sorry guys, maybe it is. It was authored by a name I didn't recognize, but maybe another consultant imported it while on contract. It's simple really - parses the input for the format and spits it out as an Iconv. Nothing to it. The last posting is much simpler!

cheers,

Heather

Posted: Wed Sep 07, 2005 7:49 pm
by ray.wurlod
Suggestion to all employers of consultants: make sure (a condition of hire?) that anything the consultant leaves is tagged with the consultant's contact details, and some kind of warranty as to fitness for purpose (plus, maybe, some form of support undertaking).

You won't regret it.

Posted: Wed Sep 07, 2005 8:20 pm
by chulett
Suggestion to all consultants of employers: include something like this in all your work.
This code is provided "AS IS" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement.
:wink:

(just joking Ray)