从 Postgresql EPOCH 列中减去日期

Subtracting Day from Postgresql EPOCH Column

我有以下代码,我试图从日期中简单地减去 5 天。日期以 EPOCH 时间(毫秒,13 个数字)存储在 t.Date_created 字段中。但由于某种原因,代码无法使用以下错误。任何建议都会有帮助!!!

[42883] ERROR: operator does not exist: timestamp with time zone - integer Hint: No operator matches the given name and argument types. You might need to add explicit type casts.

代码如下:

SELECT to_timestamp(t.date_Created / 1000) - 5 FROM task_mgmt.teams t LIMIT 5;

我建议算术:

t.date_created - 5 * 24 * 60 * 60 * 1000

你需要减去一个interval

to_timestamp(t.date_Created / 1000) - interval '5 days'

整数只能直接从 date 值中减去,不能从 timestamp 值中减去。