postgresql中MS SQL Server的getutcdate()的等价性是什么?

时间:2015-05-05 17:50:16

标签: sql-server postgresql

我从SQL Server迁移到PostgreSQL。如何翻译getutcdate函数,如:

Insert into mytable (mypk, toucheddate) values (99, getutcdate() )

(我不是要求相当于MySQL,这是一个不同的平台)

3 个答案:

答案 0 :(得分:7)

至少有两种获取UTC当前时间的方法:

select now() at time zone 'utc';

select current_timestamp at time zone 'utc';

答案 1 :(得分:0)

Postgres的当前日期和时间为current_timestamp,当前日期为current_date,当前时间为current_time

其他详情可在the documentation

中找到

答案 2 :(得分:0)

我相信您正在寻找now()

postgres=# select now();
            now
---------------------------
 2015-05-05 13:52:45.81-04
(1 row)