'convert unix epoch to date in Redshift

I'm working on a project in AWS redshift and I have date column in this form 1541105830796 (unix epoch) and I need to convert it to this form 'YYYY-MM-DD HH-mm-ss'. How can I do that in AWS Redshift?



Solution 1:[1]

Assuming it's an epoch timestamp, you need to use DATEADD() to calculate the seconds since 1970-01-01:

SELECT 
      DATEADD(s, time_column, '1970-01-01') as date_time
FROM yourtable

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1