Hi,
In Oracle database, add_months returns the last day of the resulting month if the input date is the last day of the month.
SQL> select add_months('2018-11-30', 1) from dual;
ADD_MONTHS('2018-11
-------------------
2018-12-31 00:00:00
In orafce, pg_catalog.add_months works well, but oracle.add_months does not.
postgres=# select pg_catalog.add_months('2018-11-30', 1) from dual;
add_months
------------
2018-12-31
(1 row)
postgres=# select oracle.add_months('2018-11-30', 1) from dual;
add_months
---------------------
2018-12-30 00:00:00
(1 row)
The problem is that oracle.add_months is not implemented for the case of the last day of the month as following.
CREATE FUNCTION oracle.add_months(TIMESTAMP WITH TIME ZONE,INTEGER)
RETURNS TIMESTAMP
AS $$ SELECT ($1 + interval '1 month' * $2)::oracle.date; $$
LANGUAGE SQL IMMUTABLE STRICT;
Regards,
Ryohei Takahashi