使用:
-
Suabase中的PostgreSQL 14
-
格拉法纳云
我正在尝试转换
BIGINT
时间戳(以毫秒为单位)
TIMESTAMPZ
在里面
PostgreSQL 14
。
这个
BIGINT
是存储在
$__to
和
$__from
。我正在尝试使用此查询查询特定时间范围内的数据:
SELECT
"timestamp" AS "time",
etalon,
humidity,
temperature
FROM "values"
WHERE
timestamp >= TO_TIMESTAMP($__from, 'DD/MM/YYYY HH24:MI:SS')
and timestamp < TO_TIMESTAMP($__to, 'DD/MM/YYYY HH24:MI:SS')
上面的查询导致了此错误:
function to_timestamp(bigint, unknown) does not exist
我已经研究了这些主题,但找不到可行的解决方案:
-
Postgres timestamp to unix time in milliseconds as a bigint
-
https://dba.stackexchange.com/questions/215354/convert-date-format-into-bigint-format-in-postgresql
-
How to format bigint field into a date in Postgresql?
编辑
使用
Quassnoi
解决方案也不起作用:
SELECT
"timestamp" AS "time",
etalon,
humidity,
temperature
FROM "values"
WHERE
timestamp >= TO_CHAR(TO_TIMESTAMP(1644770125499 / 1000), 'DD/MM/YYYY HH24:MI:SS')
and timestamp < TO_CHAR(TO_TIMESTAMP(1644770125499 / 1000), 'DD/MM/YYYY HH24:MI:SS')
结果:
operator does not exist: timestamp with time zone >= text
使用评论中的建议,我确实转换了BIGINT,但我得到了看起来很奇怪的时间戳:
我的时间戳栏的类型: