ADD_MONTHS Function - Oracle to MySQL Migration

In Oracle, ADD_MONTHS function adds the number of month to the specified date value. In MySQL, 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:28:52

MySQL:

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

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

For more information, see Oracle to MySQL Migration.