Page 1 of 1

String to Date conversion issue

Posted: Mon Jun 11, 2012 1:01 am
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

Posted: Mon Jun 11, 2012 2:06 am
by zulfi123786
you need to use as shown

Code: Select all

 Iconv(input.Date,"D-YMD")

Posted: Mon Jun 11, 2012 2:11 am
by ray.wurlod
What is your default date format for Teradata? (You may need to ask your DBA.)

Posted: Mon Jun 11, 2012 2:25 am
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

Posted: Mon Jun 11, 2012 6:27 am
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?

Posted: Mon Jun 11, 2012 8:37 pm
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.

Posted: Mon Jun 11, 2012 9:13 pm
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... :?

Posted: Mon Jun 11, 2012 9:18 pm
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.

Posted: Mon Jun 11, 2012 9:52 pm
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.

Posted: Tue Jun 12, 2012 12:21 am
by ray.wurlod
Oracle is ...
_________________ ... different