SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software SQL Server 2012 Download and T-SQL Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.

download SQL Server 2016
download SQL Server 2014
download SQL Server 2012

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

SELECT EOMONTH (@current_date) AS 'The last date of Current Month'

SQL last date of month calculation in SQL Server 2011

Now T-SQL programmers can pass the offset argument value of the SQL EOMonth function, instead of the default 0 value.

 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'

SQL EOMonth() datetime function for end of month calculation

Related SQL Resources

SQL Server Articles

SQL Server 2012

SQL Server Tools

SQL Blog

SQL Server 2008 Blog

Certification Exams Blog

Reporting Services Blog

Analysis Services Blog

MS SQL Server Forums

Copyright © 2004 - 2017 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems