Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.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
Sql 将时间戳格式化为1/100秒/1/10秒_Sql_Postgresql - Fatal编程技术网

Sql 将时间戳格式化为1/100秒/1/10秒

Sql 将时间戳格式化为1/100秒/1/10秒,sql,postgresql,Sql,Postgresql,在PostgreSQL中,我可以将时间戳格式化为秒,如下所示 to_时间戳('2017-02-20 08:22:44.166','YYYY-MM-DD HH24:MI:SS')-->2017-02-20 08:22:44 我需要将上面的时间戳格式化为100秒和10秒 -->2017-02-20 08:22:44.17(格式为1/100秒) -->2017-02-20 08:22:44.2(格式为1/10秒)向 select '2017-02-20 08:22:44.166'::timestamp

在PostgreSQL中,我可以将时间戳格式化为秒,如下所示

to_时间戳('2017-02-20 08:22:44.166','YYYY-MM-DD HH24:MI:SS')-->2017-02-20 08:22:44

我需要将上面的时间戳格式化为100秒和10秒

-->
2017-02-20 08:22:44.17
(格式为1/100秒)

-->
2017-02-20 08:22:44.2
(格式为1/10秒)

select '2017-02-20 08:22:44.166'::timestamp(2), '2017-02-20 08:22:44.166'::timestamp(1)

       timestamp        |       timestamp       
------------------------+-----------------------
 2017-02-20 08:22:44.17 | 2017-02-20 08:22:44.2
(1 row)