Skip to content

SQL Server 2012 – Enter the EOMONTH Function

August 2, 2012

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


From → SQL

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: