8

I have a column of dates in a Redshift table. I would like the output to be in the form of unix timestamps. Essentially, I want the opposite of this question: How to convert epoch to datetime redshift?

Is there a way to do this?

1
  • can you show the format of your dates? Commented Jun 9, 2017 at 16:23

2 Answers 2

9

Date_part is dead. Use extract() now --

SELECT extract(epoch from CURRENT_DATE)
Sign up to request clarification or add additional context in comments.

Comments

8

You can just use EPOCH with DATE_PART.

select date_part(epoch, date_column)
from tbl  

From the documentation

The Amazon Redshift implementation of EPOCH is relative to 1970-01-01 00:00:00.000000 independent of the time zone where the server resides. You might need to offset the results by the difference in hours depending on the time zone where the server is located.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.