Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Ziek's SQL Home

Ezekiel is an IT professional with over ten years experience in building database applications and BI/DW solutions. He holds a BSc Computer Science degree from KNUST, Ghana and a MSc Business IT degree from Kingston Business School, London. He has delivered solutions for the Insurance, Banking, Telecom and Housing Industries and his key expertise include developing Microsoft BI/DW solutions, .NET applications, Business Process Improvement and Project Risk Management. He is a Microsoft Certified Professional - MCTS: Microsoft SQL Server 2005 Implementation and Maintenance.

SQL Server 2012 – Enter the EOMONTH Function

In this blog post, I will be sharing a new date feature in SQL Server 2012 called the EOMONTH (End of Month) which is used to find or get the last day of a month in a specified date.

In prior versions of SQL Server 2012, date functions like “dateadd” and/or “datediff” were invaluable in finding the last day of a month.

Consider a SQL Server 2005/2008 R2 example of how we find the last day of a month;


The use of the date functions in the example above returns a date value of 2012-08-31 00:00:00.000 (see red arrow).

Now this same result can be achieved by using the EOMONTH function in SQL Server 2012 as shown below;



SET @date = ‘20120802’


This returns ‘2012-02-31’


Thanks for reading and hope you’ve gained something.



For additional reading, please see



Leave a comment on the original post [, opens in a new window]

Loading comments...