Cast timestamp to integer in Redshift

Viewed 6884

I'm trying to cast or convert a timestamp column to an integer value in a Redshift database. I know it is possible in other SQL-based databases and I've done this before, however in Redshift I can't get it to work.

I've tried some variations of cast and also convert (http://docs.aws.amazon.com/redshift/latest/dg/r_CAST_function.html).

Here is an example:

SELECT cast(finish_time as integer) FROM table;

It gives me the error message:

SQL Error Invalid operation: cannot cast type timestamp without time zone to integer;

Is it possible to get a timestamp as an integer?

1 Answers
Related