Need help Converting a varchar field to a date

Database
Enthusiast

Need help Converting a varchar field to a date

I am loading a varchar field into a temp table via fastload from a TXT file. I need to insert the data in a perm table and conver the below field to a date format MM/DD/YYYY.

 

Can I convert during the load or when I insert from temp table to perm table?

 

Here is the field as a varchar - 2017-05-24 19:41:49

 

 

 

1 REPLY
Teradata Employee

Re: Need help Converting a varchar field to a date

The display format of a date or timestamp is specified in the table definition (Create Table - see the SQL DDL manual at info.teradata.com for all the gory details) and can be overridden by the select statement (SQL DML manual).  Teradata stores the date or timestamp in its own internal format, so you don't need to worry about that.

So define the mm/dd/yyyy format in the perm table itself, and fastload the field as a timestamp - or, if you really just want the date, define the date portion of the field with the format yyyy-mm-dd and define the time portion as a filler.