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 with the MONTH datetime unit.

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:

  -- -- 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.