dataengref migrate

Home / Oracle

Oracle MONTHS_BETWEEN in Snowflake, Databricks and BigQuery

Snowflake and Databricks keep MONTHS_BETWEEN with Oracle-style fractions based on 31-day months. BigQuery has no equivalent; DATE_DIFF(..., MONTH) returns whole month boundaries only.

Oracle function: MONTHS_BETWEEN(date1, date2) · Oracle docs

Equivalents

TargetSupportSyntaxNotesSource
SnowflakeSame nameMONTHS_BETWEEN(date_expr1, date_expr2)Fraction based on 31-day months; the same day of month gives a whole number.Snowflake docs
DatabricksSame namemonths_between(expr1, expr2 [, roundOff])Fraction based on 31 days per month, rounded to 8 digits unless roundOff is false.Databricks docs
BigQueryRewriteDATE_DIFF(date1, date2, MONTH)Counts month boundaries and returns an integer, not a fraction.BigQuery docs

Behavior differences to check

Databricks

BigQuery

Examples

Tenure in months

Oracle
SELECT emp_id, MONTHS_BETWEEN(SYSDATE, hire_date) AS tenure_months FROM employees;
Snowflake
SELECT emp_id, MONTHS_BETWEEN(CURRENT_DATE, hire_date) AS tenure_months FROM employees;
Databricks
SELECT emp_id, months_between(current_date(), hire_date) AS tenure_months FROM employees;
BigQuery
SELECT emp_id, DATE_DIFF(CURRENT_DATE(), hire_date, MONTH) AS tenure_months FROM employees;

Other Oracle functions

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