dataengref migrate

Home / SQL Server

SQL Server EOMONTH in Snowflake, Databricks and BigQuery

None of the targets has EOMONTH. Use LAST_DAY, which all three support. For the optional month offset, add the months first and then take LAST_DAY.

SQL Server function: EOMONTH(start_date [, month_to_add]) · SQL Server docs

Equivalents

TargetSupportSyntaxNotesSource
SnowflakeRewriteLAST_DAY(date_or_time_expr [, date_part])Returns a DATE. The optional date_part also gives the last day of a year, quarter or week.Snowflake docs
DatabricksRewritelast_day(expr)Returns the last day of the month as a DATE.Databricks docs
BigQueryRewriteLAST_DAY(date_expression [, date_part])Returns a DATE. Also accepts DATETIME with DATETIME-specific parts.BigQuery docs

Behavior differences to check

Examples

Month-end date for each invoice, and the end of next month

SQL Server
SELECT EOMONTH(invoice_date) AS month_end, EOMONTH(invoice_date, 1) AS next_month_end FROM invoices;
Snowflake
SELECT LAST_DAY(invoice_date) AS month_end, LAST_DAY(DATEADD(month, 1, invoice_date)) AS next_month_end FROM invoices;
Databricks
SELECT last_day(invoice_date) AS month_end, last_day(add_months(invoice_date, 1)) AS next_month_end FROM invoices;
BigQuery
SELECT LAST_DAY(invoice_date) AS month_end, LAST_DAY(DATE_ADD(invoice_date, INTERVAL 1 MONTH)) AS next_month_end FROM invoices;

Other SQL Server functions

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