String to Date conversion issue

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
dxk9
Participant
Posts: 105
Joined: Wed Aug 19, 2009 12:46 am
Location: Chennai, Tamil Nadu

String to Date conversion issue

Post by dxk9 »

Hi,

I have a input sequential file with a field value '2010-05-16'. Need to convert this into Date & load it into a Teradata table.

Based on Dsxchange suggestions, I tried different combinations of oconv & iconv. But it doesn't work.

The error says:

Value treated as NULL
Attempt to convert String value "" to Date type unsuccessful

Please help !!

Thanks,
dxk9
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Post by zulfi123786 »

you need to use as shown

Code: Select all

 Iconv(input.Date,"D-YMD")
- Zulfi
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What is your default date format for Teradata? (You may need to ask your DBA.)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dxk9
Participant
Posts: 105
Joined: Wed Aug 19, 2009 12:46 am
Location: Chennai, Tamil Nadu

Post by dxk9 »

Zulfi,

Thanks !! Your suggestion worked :)

Ray,

As of now its working, will also know the Teradata default date format from DBAs for future reference.

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

Post by chulett »

So Teradata needs the date in internal format? Don't recall hearing that before. Have you verified that you get the correct date in the database rather than it works because the job no longer throws the error?
-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 »

I would expect a server job to behave this way. One exception is ODBC, where you have to specify this behaviour by specifying Date as the data element.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sorry for being especially dense tonight but why would you 'expect a Server job to behave this way'? I must be missing something fundamental here... :?
-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 »

Because, in server jobs, the representation of the Date data type is "internal format". Most Connectors (and their predecessors) perform the conversion automatically where the metadata are consistent.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ah... having dealt basically 100% with Oracle where I would always treat a DATE as a full Timestamp with explicit control over the time portion, that never really clicked for me.
-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 »

Oracle is ...
_________________ ... different
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