Trouble casting a col with char datatype DATE to date datatype DATE

UDA
N/A

Trouble casting a col with char datatype DATE to date datatype DATE

Hi,

I am having an issue with casting a col with char(10) datatype to date datatype.

(i) If I use:

CAST('2009-11-25' As date) As dt
its working

(ii) Now, I have a column () with dates in . If I try to convert the dates in that col to date datatype....its NOT working.
SELECT CAST(start_date As date) As dt
FROM

I tried working on the CAST statement in different ways...to convert character datatype DATE to Date datatype DATE...none of them worked.
If there is any way, please let me know. Thanks
1 REPLY

Re: Trouble casting a col with char datatype DATE to date datatype DATE

Instead of directly casting u must give the format in which u r storing the data in char column.. suppose ur column contains the values like '19-01-2009' then you must use

select cast('19-01-2009' as date format 'dd-mm-yyyy');

By default teradata stores the dates in yyyy-mm-dd and i doubt your column is having the data in same format...Please check