EOMONTH function in SQL

The EOMONTH function in SQL returns the last day of the month for a given date, with an optional parameter to specify the number of months to add or subtract.

SQL Syntax

EOMONTH(start_date, [month_to_add])

The following are the parameters of the function:

Note: EOMONTH() returns a date in YYYY-MM-DD format.

Example: Get the Last Day of the Current Month.

SQL Syntax

SELECT EOMONTH(GETDATE()) AS LastDayOfCurrentMonth;

If today's date is 2024-10-10, the result will be:

LastDayOfCurrentMonth
2024-10-31