ADD_MONTHS Function - Oracle to MariaDB Migration

In Oracle, ADD_MONTHS function adds the number of month to the specified date value. In MariaDB, you have to use TIMESTAMPADD function even in Oracle Compatibility mode.

Oracle:

  ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';
 
  -- Add 2 months to the current date
  SELECT ADD_MONTHS(SYSDATE, 2) FROM dual;
  # 2021-07-19 12:14:17

MariaDB - Oracle Compatibility:

  -- Add 2 months to the current date
  SELECT TIMESTAMPADD(MONTH, 2, SYSDATE());
  # 2021-07-19 12:14:17

Note that the order of parameters for ADD_MONTHS and TIMESTAMPADD changed.

For more information, see Oracle to MariaDB Migration - Oracle Compatibility Mode.