Iconv oconv

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
balu1625
Participant
Posts: 19
Joined: Thu Mar 04, 2010 9:16 am

Iconv oconv

Post by balu1625 »

Im getting the date in the format yyyy-mm-dd and I want to be loaded in the target in the format mm-dd-yyyy. I tried using Iconv and oconv but its saying its not valid month may be the syntax im writing is not right.

Can anyone plz help me with the syntax to convert date
format yyyy-mm-dd to mm-dd-yyyy

Thanks for your time.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Why don't you post what you have tried so others can guide you ?
balu1625
Participant
Posts: 19
Joined: Thu Mar 04, 2010 9:16 am

Post by balu1625 »

oconv(iconv(In_MTRANS_DT,'d4'),'d-ymd[4,2,2]')
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Most likely you have an invalid date somewhere.

Try

Code: Select all

OCONV(ICONV(In_MTRANS_DT,'D4-ymd'),'D4-mdy[2,2,4]')
balu1625
Participant
Posts: 19
Joined: Thu Mar 04, 2010 9:16 am

Post by balu1625 »

Thanks for replying. I check the date format and its all with yyyy-mm-dd and I have tried the syntax that was posted.

Now I get the error ORA-01861: literal does not match format string
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

That is an Oracle error.

Are you loading the result into Oracle table ? Check whether you have a TO_DATE() function and post the command as it appears.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

seems like the date format in Oracle stage is not matching the string supplied, check if it is "mm-dd-yyyy" as the function will return value in this format.

Just out of curiosity, why you are changing format if its consistant and you are loading it to a database, just change the date format picture in insert/update statement to match incoming pattern.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
balu1625
Participant
Posts: 19
Joined: Thu Mar 04, 2010 9:16 am

Post by balu1625 »

Im getting 6 digits dae (980501) and there are even 0 in the source so I need to convert the date in the Target as (MM-DD-YYYY) and store also if its 0 I need to load it as null.

The src datatype is DECIMAL and the target data type is DATE

So i have written If In_PMH_TRANS_DT = 0 Then @NULL Else ( If (In_PMH_TRANS_DT[1, 1]<='2') Then '20' :
In_PMH_TRANS_DT[2, 2] : '-' : In_PMH_TRANS_DT[4, 2]
: '-' : In_PMH_TRANS_DT[6, 2] Else '19' : In_PMH_TRANS_DT[1, 2] : '-' : In_PMH_TRANS_DT[3, 2] : '-' : In_PMH_TRANS_DT[5, 2])

This is converting the date to yyyy-mm-dd and now I want to convert it into target date format as mm-dd-yyyy for which I have written this

OCONV(ICONV(DSLink31.In_PMH_TRANS_DT),'D4-mdy[2,2,4]').

I have even tried using TO_DATE in the target insert statement with the format
(MM-dd-yyyy)

Thanks for yur time i responding to my post.

The errors Im getting are Attempt to convert String value "05-01-1995" to Date type unsuccessful
ORA-01841: (full) year must be between -4713 and +9999, and not be 0
Transformer_32: DBMS.CODE=ORA-01841
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post by arunkumarmm »

Balu, I think you had the same question in a different post. Please refer your old post
Arun
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

If you have 6 digit dates - yymmdd, you can do something like below

Code: Select all

svFormattedDate = If yourDate = 0 Then @NULL Else If yourDate[1,1] < '2' Then '20':yourDate Else '19':yourDate 
In the Oracle stage, mention the format in To_Date() as YYYYMMDD.

This must solve your problem.

There is also century pivot possible in both datastage and oracle. You may choose one of them in your case to avoid all.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What is "plz"?

In German it's the abbreviation for Postleitzahl (postal code), but you're not writing in German.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply