All Forums Database
info9891 43 posts Joined 09/14
08 Sep 2014
How do I convert a date or timestamp to a string in Teradata

In our database we have a system-generated ID that is built off of the timestamp. It’s not a date or time format, it’s a string, like (20130405103422), which is essentially the year, month, day, hour, minute and second that the record was created. I want to join it to another field, which is date, but I need to convert it first. How do I do that

Priya01 10 posts Joined 08/14
08 Sep 2014

Try using the below query,
cast(cast('20130405233422' as timestamp(0) format 'YYYYMMDDHHMISS') as date format 'YYYY-MM-DD')

09 Sep 2014

please try this........
select cast(current_timestamp(0) as timestamp(0) format 'YYYYMMDDHHMISS')

 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.

Current TimeStamp(0)

You must sign in to leave a comment.