Menu

SQL Server EOMONTH() Function

EOMONTH(start_date [, month_to_add]) returns the last calendar date of the month containing start_date. The optional month_to_add argument moves the starting date by a number of months before returning that month’s last date. EOMONTH() is available in SQL Server 2012 and later. See Microsoft’s EOMONTH documentation.

Syntax

EOMONTH(start_date [, month_to_add])

The return type is date, even when the input includes a time. month_to_add can be positive, zero, or negative; the function returns an error if the resulting date is outside the supported range.

Examples

Return the current month’s final date and the final dates of the next and previous months:

DECLARE @date date = '2024-12-31';

SELECT EOMONTH(@date) AS current_month_end,
       EOMONTH(@date, 1) AS next_month_end,
       EOMONTH(@date, -1) AS previous_month_end;

Result:

current_month_end next_month_end previous_month_end
2024-12-31 2025-01-31 2024-11-30

EOMONTH() is useful for month-end boundaries. To truncate a value to the first day of a month, use DATETRUNC(month, value). For other date arithmetic, see DATEADD().