如何在current_timestamp SQL(Oracle)中增加10秒 [英] How to add 10 seconds in current_timestamp SQL ( Oracle )
问题描述
我想在我的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屋!