在时间戳中添加秒 [英] Add seconds into timestamp

查看:1252
本文介绍了在时间戳中添加秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to add seconds into the given timestamp.

示例

给定时间:

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

现在我想添加一些 20秒

在SQL Server中,我使用了 DATEADD 。但是我搜索后发现PostgreSQL没有提供这种功能。

In SQL Server I have used DATEADD. But I searched and come to know that there is no such function provided by PostgreSQL.

解决方案是什么?

推荐答案

只需添加 20秒:

t1 := t1 + interval '20' second;






PL / pgSQL中的赋值运算符为:= = 仅用于向后兼容。不要使用它。


The assignment operator in PL/pgSQL is :=. The = is only there for backward compatibility. Don't use it.

这篇关于在时间戳中添加秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆