0

How can i convert a timestamp (formatted this way: 1,437,538,735.00) into date and time (such as 2016-11-23 14:00:00) in Teradata SQL?

Thank you!

Bhavesh Ghodasara
  • 1,981
  • 2
  • 15
  • 29

3 Answers3

0

This looks like a Unix format for the time, so it is the number of seconds since 1970-01-01. Something like this should work:

select timestamp '1970-01-01 00:00:00' + interval '1437538735' second

I don't have Teradata on hand to specifically test the syntax.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
0

Try this:

select CAST(DATE '1970-01-01' + (1437538735 / 86400) AS TIMESTAMP(0)) + ((1437538735 MOD 86400) * INTERVAL '00:00:01' HOUR TO SECOND) td_ts
Bhavesh Ghodasara
  • 1,981
  • 2
  • 15
  • 29
0
select timestamp '1970-01-01 00:00:00' + 1437538735 * interval '0 00:00:01' day to second

P.s.
With this syntax you can use a colum/expression instead of the hard-coded value

David דודו Markovitz
  • 42,900
  • 6
  • 64
  • 88