如何在current_timestamp SQL(Oracle)中增加10秒 [英] How to add 10 seconds in current_timestamp SQL ( Oracle )

查看:305
本文介绍了如何在current_timestamp SQL(Oracle)中增加10秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的PL/SQL脚本中向current_timestamp添加10秒.我尝试了下面的代码,但它的输出不是时间戳格式.

I want to add 10 seconds to current_timestamp in my PL/SQL script. I tried below code but it's output is not in timestamp format.

SELECT CURRENT_TIMESTAMP+1/24/60/6 FROM dual;

输出:

CURRENT_TIMESTAMP+1/24/60/6

---------------------------
28-AUG-15

Mysql服务器中是否有类似于TIMESTAMPADD的功能?

Is there any function similar to TIMESTAMPADD in Mysql server?

推荐答案

在Oracle中,如果您希望将timestamp而不是date作为结果(date始终包含到秒的时间,但是,因此您可能只需要date),则想将interval添加到timestamp.构造间隔的方法有多种-您可以使用间隔文字

In Oracle, if you want a timestamp as the result, rather than a date (a date always includes the time to the second, though, so you may just want a date), you'd want to add an interval to the timestamp. There are various ways to construct an interval-- you can use an interval literal

select current_timestamp + interval '10' second
  from dual

或者您可以使用numtodsinterval函数

select current_timestamp + numToDSInterval( 10, 'second' )
  from dual

这篇关于如何在current_timestamp SQL(Oracle)中增加10秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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