将秒添加到时间戳

问题描述:

我想在给定的时间戳中添加秒。将秒添加到时间戳

鉴于时间:

Declare 
     t1 timestamp = '1900-01-01 02:00:00'; 

现在我想一些20 seconds加入到给定的时间。

在SQL Server中,我使用了DATEADD。但是我搜索并了解到PostgreSQL没有提供这样的功能。

什么是解决方案?

+1

只需检查日期/时间运营商:http://www.postgresql.org/docs/current/interactive/functions-datetime.html – 2015-02-23 11:50:46

+0

@FrankHeikens,是啊!得到它了。谢谢 – MAK 2015-02-23 11:55:04

Just add 20秒时:

t1 := t1 + interval '20' second; 

用PL/pgSQL赋值运算符是:==只是为了向后兼容。不要使用它。

+0

非常感谢。 – MAK 2015-02-23 11:55:25

+0

你能帮我这个吗:http://stackoverflow.com/questions/28337765/postgresql-9-3-dynamic-pivot-table – MAK 2015-02-26 12:00:07