Home > Software engineering >  convert unix epoch to date in Redshift
convert unix epoch to date in Redshift

Time:04-18

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?

CodePudding user response:

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
  • Related