Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Type conversion 红移:毫秒到时间戳_Type Conversion_Timestamp_Amazon Redshift - Fatal编程技术网

Type conversion 红移:毫秒到时间戳

Type conversion 红移:毫秒到时间戳,type-conversion,timestamp,amazon-redshift,Type Conversion,Timestamp,Amazon Redshift,假设我们有两张桌子: CREATE TABLE IF NOT EXISTS tech_time( ms_since_epoch BIGINT ); CREATE TABLE IF NOT EXISTS readable_time( ts timestamp without time zone, ); 假设tech\u time有数据,我们希望填充readable\u time 因此,在Postgres中,您可以使用来添加时间戳(双精度)并执行以下操作 INSERT INTO

假设我们有两张桌子:

CREATE TABLE IF NOT EXISTS tech_time(
    ms_since_epoch BIGINT
);

CREATE TABLE IF NOT EXISTS readable_time(
    ts timestamp without time zone,
);
假设
tech\u time
有数据,我们希望填充
readable\u time

因此,在Postgres中,您可以使用
来添加时间戳(双精度)
并执行以下操作

INSERT INTO readable_time(ts)
SELECT DISTINCT to_timestamp(ms_since_epoch::float / 1000) AS ts,
FROM tech_time;
亚马逊红移中似乎不存在这样的功能:

时间戳(双精度)的函数不存在


我的问题是:如何在损失最小精度的情况下正确填充
readable\u time

INSERT INTO readable_time (ts)
SELECT DATEADD(ms, ms_since_epoch, '1970-01-01 00:00:00')
FROM tech_time;