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
| Target | Support | Syntax | Notes | Source |
|---|---|---|---|---|
| Snowflake | Rewrite | LAST_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 |
| Databricks | Rewrite | last_day(expr) | Returns the last day of the month as a DATE. | Databricks docs |
| BigQuery | Rewrite | LAST_DAY(date_expression [, date_part]) | Returns a DATE. Also accepts DATETIME with DATETIME-specific parts. | BigQuery docs |
Behavior differences to check
- EOMONTH(d, n) has no single-function equivalent. Write LAST_DAY(DATEADD(month, n, d)) in Snowflake, last_day(add_months(d, n)) in Databricks and LAST_DAY(DATE_ADD(d, INTERVAL n MONTH)) in BigQuery.
Examples
Month-end date for each invoice, and the end of next month
SELECT EOMONTH(invoice_date) AS month_end, EOMONTH(invoice_date, 1) AS next_month_end FROM invoices;SELECT LAST_DAY(invoice_date) AS month_end, LAST_DAY(DATEADD(month, 1, invoice_date)) AS next_month_end FROM invoices;SELECT last_day(invoice_date) AS month_end, last_day(add_months(invoice_date, 1)) AS next_month_end FROM invoices;SELECT LAST_DAY(invoice_date) AS month_end, LAST_DAY(DATE_ADD(invoice_date, INTERVAL 1 MONTH)) AS next_month_end FROM invoices;