时间:2021-07-01 10:21:17 帮助过:3人阅读
增加一小时
SELECT to_char(systimestamp + NUMTODSINTERVAL(1,‘hour‘),‘yyyy-mm-dd HH24:mi:ss:ff‘), to_char(systimestamp,‘yyyy-mm-dd HH24:mi:ss:ff‘) FROM dual;
增加一分钟
SELECT to_char(systimestamp + NUMTODSINTERVAL(1,‘minut‘),‘yyyy-mm-dd HH24:mi:ss:ff‘), to_char(systimestamp,‘yyyy-mm-dd HH24:mi:ss:ff‘) FROM dual;
对numtodesignterval 的原版解释如下:
NUMTODSINTERVAL converts n to an INTERVAL DAY TO SECOND literal. The argument n can be any NUMBER value or an expression that can be implicitly converted to a NUMBER value. The argument interval_unit can be of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 datatype. The value for interval_unit specifies the unit of n and must resolve to one of the following string values:
从解释上看,NUMTODSINTERVAL函数还可以处理day和sesond的值增加,(处理值减少只要添加“-”在数字前就可以啦),真是很强大的函数。另外如果需要增加的是年或者月,
要选择NUMTOYMINTERVAL 函数了
Oracle timestamp 类型增加值的问题
标签: