This query works withour errors
select add_months(date '2011-01-31', 1) from dual;
, while this one:
select date '2011-01-31' + interval '1' month from dual;
returns
ORA-01839: date not valid for month specified
So is there any safe way to add interval using INTERVAL literal?
This follows ANSI-specified behavior1 of adding
INTERVALs to dates. This is also documented here:The function
ADD_MONTHSon the other hand will just give you the last day of the month if the resulting month has less days – and I believe this function was created to address this issue.1 http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt