尝试在redshift中将bigint 1549757162511
转换为timestamp
。
select 1549757162511::timestamp;
失败cannot cast type bigint to timestamp without time zone
select timestamp 'epoch' + 1549757162511 / 1000 * interval '1 second';
2019-02-10 00:06:02.000000
没有毫秒
select dateadd(milliseconds, 1549757162511 % 1000, (timestamp 'epoch' + 1549757162511 / 1000 * interval '1 second'));
2019-02-10 00:06:02.511000
时区为UTC
答案 0 :(得分:1)
找到了另一种方法。不知道它是否更好,但它是def。清洁工。
(timestamp 'epoch' + 1549757162511::numeric / 1000 * interval '1 second')
答案 1 :(得分:0)
这也可以:
(timestamp 'epoch' + 1549757162511 * interval '0.001 seconds')