Calculate SQL Last Day of Month using End of Month EOMonth() Function in SQL Server 2011
SQL Server EOMonth() function returns the last day of the month that the input argument start_date is in that month.
There is an optional input parameter offset, which helps T-SQL developers to find the end of month that is N months later or before the input start date argument.
The default value of offset parameter month to add or month to substract is 0.
EOMONTH (start_date [, month_to_add])
SQL EOMonth datetime function is first introduced to SQL Server developers with the release of Denali CTP3.
Here is a few SQL code where the new datetime function EOMonth is used to calculate the last date of the month where the input date parameter is in
DECLARE @current_date DATETIME = GETDATE()
SELECT EOMONTH (@current_date) AS 'The last date of Current Month'

Now T-SQL programmers can pass the offset argument value of the SQL EOMonth function, instead of the default 0 value.
DECLARE @current_date DATETIME = GETDATE()
SELECT
EOMONTH (@current_date, -1) AS 'The last date of Previous Month',
EOMONTH (@current_date) AS 'The last date of Current Month',
EOMONTH (@current_date, 1) AS 'The last date of Next Month'

|