我有一个包含 3 列的简单表格
id, 时间戳, 用户名
id 是整数 时间戳是 int 用户名是varchar
我正在尝试将这些时间戳设置为日期格式或正确的时间戳以在数据集中使用它,但由于“年份”部分未正确显示,因此我可能会在这里遗漏一些内容。
这是我迄今为止尝试过的:
select
table.id,
table.timestamp,
to_timestamp(table.timestamp),
table.username
from table
select
table.id,
table.timestamp,
to_char(to_timestamp(table.timestamp), 'dd-mm-yyyy'),
table.username
from table```
我找到了另一条评论中所述的解决方案:
select to_timestamp(table.timestamp/ 1000)::date;