今天做关于日期函数的联系,意外的发现了一个可以叫做bug的地方吧。
这个是关于TO_YMINTERVAL()函数的
TO_YMINTERVAL
Description of the illustration to_yminterval.gif
TO_YMINTERVAL
converts a character string of CHAR
, VARCHAR2
, NCHAR
, or NVARCHAR2
datatype to an INTERVAL
YEAR
TO
MONTH
type, where char
is the character string to be converted.
The following example calculates for each employee in the sample hr.employees
table a date one year two months after the hire date:
SELECT hire_date, hire_date + TO_YMINTERVAL('01-02') "14 months" FROM employees; HIRE_DATE 14 months --------- --------- 17-JUN-87 17-AUG-88 21-SEP-89 21-NOV-90 13-JAN-93 13-MAR-94 03-JAN-90 03-MAR-91 21-MAY-91 21-JUL-92
上边这段内容明眼人一看编制出自 oracle的 SQL Reference。
言归正传,我所说的bug是这样的,我的表里有这么一个日期‘1980-12-29’,我要算一年两个月之后的日期
SELECT TO_DATE('1980-12-29','YYYY-MM-DD')+TO_YMINTERVAL('01-02') FROM DUAL;
这里就使用了TO_YMINTERVAL()函数,结果我郁闷了,‘ORA-01839 :指定月份的日期无效’。