我有這樣的查詢:
select
(featuremap ->> 'column.time:value')
from db.table;
這會將 unix 時間戳作為字串值回傳。我嘗試了幾件事:例如:
select
extract(epoch from(featuremap ->> 'column.time:value'))
from db.table;
回傳此錯誤:ERROR: function pg_catalog.date_part(unknown, text) does not exist
和:
select
to_timestamp(featuremap ->> 'column.time:value')
from db.table;
回傳此錯誤:ERROR: function to_timestamp(text) does not exist
在這種情況下,我需要做什么才能從 unix 時間戳字串/文本欄位中獲取日期和時間?
uj5u.com熱心網友回復:
將to_timestamp與單個紀元引數一起使用。由于引數的原始型別是text它需要首先轉換為數字型別。
select
to_timestamp((featuremap ->> 'column.time:value')::double precision)
from db.table;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/533670.html
