2017-07-31 18 views
1

我試圖將時間戳列轉換或轉換爲Redshift數據庫中的整數值。我知道在其他基於SQL的數據庫中可能會出現這種情況,而我之前已經這樣做了,但是在Redshift中,我無法使其工作。將時間戳記轉換爲Redshift中的整數

我試過castconverthttp://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;

是否有可能得到一個時間戳作爲整數?

回答

3

嘗試select extract('epoch' from finish_time),它會給你Unix時間戳

+0

謝謝,這就是我正在尋找。 –

相關問題