增加一小時
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 函數了