String to Date Format

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
kumar66
Participant
Posts: 265
Joined: Thu Jul 26, 2007 12:14 am

String to Date Format

Post by kumar66 »

Hi All,

I need to change the string to date. My source has the value 20070125 and I need to chnage it date. My tagret is Teradata.

I used

" Oconv(Iconv(Input._DT, "DYMD"), "D-YMD[4,2,2])" .

But the row is geting rejected.

Please Advise.

Thanks & Regards,
Kumar66
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What format does Teradata require?
Your Iconv() function is good.
Your Oconv() function is good only if Teradata requires YYYY-MM-DD format.
What error message is logged?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar66
Participant
Posts: 265
Joined: Thu Jul 26, 2007 12:14 am

Post by kumar66 »

Hi Ray,

I am getting following warning:

Value treated as NULL
Attempt to convert String value "2007-01-25" to Date type unsuccessful.


My target format is "YYYY-MM-DD".

Thanks & Regards,
Kumar66
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Apparently, that must not be your target date format or all would be working. Can you check with your TeraData DBA how it should be formatted?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Please post the full warning. We need to know where it is being generated.

If it is being generated in the Transformer stage (no Teradata stamps in the message) then the derivation is awry (which I doubt).

Break up the expression into two stage variables, one with the Iconv() and one with the Oconv() function. Use stage tracing or the Debugger to determine whether it is the Iconv() or Oconv() function that is failing, or neither.

If the message is stamped as having been generated by Teradata (or by an ODBC driver), then verify that the expected date format is as you posted. Don't assume, check.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Saad
Participant
Posts: 16
Joined: Fri Nov 04, 2005 11:50 pm
Location: Islamabad

Post by Saad »

Kumar,

Try inserting the record simply using Iconv(Input._DT, "DMYD"), actually this generates an internal value which Teradata recognizes and inserts properly. We had been doing this in one of our projects.

Regards,

Saad
kumar66
Participant
Posts: 265
Joined: Thu Jul 26, 2007 12:14 am

Post by kumar66 »

Hi Ray,

I have posted the full warning :

Stg..TX_MTRF: At row 1, link "out_TRF", while processing column "EFF_DT"
Value treated as NULL
Attempt to convert String value "2007-01-25" to Date type unsuccessful

Stg..TX_MTRF: Column EFF_DT cannot be null.
Stg..TX_MTRF: EFF_DT = NULL FRCH_ID = 1249 RTL_CTRY_CD = PH FRCH_LOC_ID = ABCD TRF_QTY = 5





Thanks & Regards,
Kumar66
kumar66
Participant
Posts: 265
Joined: Thu Jul 26, 2007 12:14 am

Post by kumar66 »

Hi Saad,

Thanks for your suggestion. I tried the way you suggested me . But the rows are getting rejected.

Thanlks & Regards,
Kumar66
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Try once again Saad's suggestion with mask "DYMD[4,2,2]"
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kumar66
Participant
Posts: 265
Joined: Thu Jul 26, 2007 12:14 am

Post by kumar66 »

Hi DSguru2B,

I tried that , it working but when I open the Teradata API stage and view the data it has internal value " 14270" instead "2007-01-25".


Thanks & Regards,
Kumar66
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Extend the column, you should see the proper format also. Anywho, check for the data using your favourite sql tool, not DataStage. This way you will be able to tell for sure.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kumar66
Participant
Posts: 265
Joined: Thu Jul 26, 2007 12:14 am

Post by kumar66 »

Hi DSguru2B,

Thanks for your reply. Yes .I am able to view the correct date format in Teradata SQL Assistant.


But the Teradata stage shows the internal format. Just curious , why it gives the internal format.

Thanks & Regards,
Kumar66
Post Reply