dataengref migrate

Home / Oracle

Oracle ADD_MONTHS in Snowflake, Databricks and BigQuery

Snowflake ADD_MONTHS keeps the Oracle month-end rule. Databricks add_months and BigQuery DATE_ADD accept the call but only clamp to month end when the day does not exist, so Feb 28 + 1 month gives Mar 28 instead of Mar 31.

Oracle function: ADD_MONTHS(date, integer) · Oracle docs

Equivalents

TargetSupportSyntaxNotesSource
SnowflakeSame nameADD_MONTHS(date_or_timestamp_expr, num_months_expr)If the input is the last day of a month, the result is the last day of the result month, as in Oracle.Snowflake docs
DatabricksSame nameadd_months(startDate, numMonths)Returns a DATE. Clamps to the end of the month only when the day does not exist.Databricks docs
BigQueryRewriteDATE_ADD(date, INTERVAL n MONTH)Clamps to the end of the month only when the day does not exist.BigQuery docs

Behavior differences to check

Snowflake

Databricks

BigQuery

Examples

Contract end date 12 months after start

Oracle
SELECT contract_id, ADD_MONTHS(start_date, 12) AS end_date FROM contracts;
Snowflake
SELECT contract_id, ADD_MONTHS(start_date, 12) AS end_date FROM contracts;
Databricks
SELECT contract_id, add_months(start_date, 12) AS end_date FROM contracts;
BigQuery
SELECT contract_id, DATE_ADD(start_date, INTERVAL 12 MONTH) AS end_date FROM contracts;

Other Oracle functions

Last checked: · Paste a whole query into the SQL checker to find every function that needs a change.