在Redshift中将时间戳转换为整数

J. *_*der 2 sql database time casting amazon-redshift

我正在尝试将时间戳列转换或转换为Redshift数据库中的整数值。我知道在其他基于SQL的数据库中也是可能的,而我之前已经做过,但是在Redshift中我无法使其正常工作。

我还尝试了cast和的一些变体converthttp://docs.aws.amazon.com/redshift/latest/dg/r_CAST_function.html)。

这是一个例子:

SELECT cast(finish_time as integer) FROM table;

它给我错误信息:

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

是否可以将时间戳记作为整数?

Ale*_*Yes 6

试试看select extract('epoch' from finish_time),它将为您提供Unix ms时间戳