Grigory P
Grigory P

Reputation: 191

Teradata: varchar to timestamp

how to convert a varchar value like 19-JAN-18 06.53.31.000000 AM to timestamp? thx

Upvotes: 0

Views: 1046

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1270793

You can use to_timestamp(). Something like this:

select to_timestamp('19-JAN-18 06.53.31.000000 AM', 'DD-MON-YY HH24.MI.SS.FF6 AM')

This uses Oracle's format model. I'm not sure if Teradata's is exactly the same.

Upvotes: 1

Fahmi
Fahmi

Reputation: 37483

You can try this

sel cast(cast(cast('19-JAN-18 06.53.31.000000 AM' as varchar(50)) as timestamp(0) format 'mm/dd/yyyyBhh:mi:ss') as timestamp(0));

Upvotes: 0

Related Questions