在postgres sql中将毫秒转换为epoch或long的函数

时间:2013-06-07 10:23:58

标签: postgresql wso2 wso2esb wso2dss

我可以使用此查询转换为秒数

SELECT TIMESTAMP 'epoch' + 1362508200000(06/032013 00:00:00)/1000
       * INTERVAL '1 second'

但我想转换成毫秒,(06/032013 00:00:00.625362)

1 个答案:

答案 0 :(得分:1)

postgres=# select extract(epoch from current_timestamp);
    date_part     
------------------
 1370602871.47581
(1 row)

postgres=# select to_timestamp(1370602871.47581);
         to_timestamp         
------------------------------
 2013-06-07 13:01:11.47581+02
(1 row)