我从SQL Server迁移到PostgreSQL。如何翻译getutcdate函数,例如:
Insert into mytable (mypk, toucheddate) values (99, getutcdate() )
(我不要求与MySQL等效,这是一个不同的平台)
我从SQL Server迁移到PostgreSQL。如何翻译getutcdate函数,例如:
Insert into mytable (mypk, toucheddate) values (99, getutcdate() )
(我不要求与MySQL等效,这是一个不同的平台)
获取当前UTC时间至少有两种方式:
select now() at time zone 'utc';
select current_timestamp at time zone 'utc';
我相信你正在寻找now()
函数:
postgres=# select now();
now
---------------------------
2015-05-05 13:52:45.81-04
(1 row)
now() at time zone 'utc'
。 - Sami KuhmonenPostgres提供current_timestamp
来获取当前日期和时间,current_date
用于获取当前日期,current_time
用于获取当前时间。
更多详细信息请参阅文档。
current_timestamp at time zone 'utc'
。 - Sami Kuhmonen