While developing SQL Scripts we may often come across the requirement of getting last day of a given month. In SQL Server 2008 R2 and it’s prior versions getting last day of any month is not an quick task, you have write a bit of T-SQL script to get it.
But with the forthcoming of SQL Server, code named Denali, it’s very easy to get last day of any month. A new function called EOMONTH is introduced to retrieve the last day
SELECT EOMONTH (GETDATE()) AS Result;
The above statement would return 2011-08-31 00:00:00 if this script is executed on any day of Aug 2011.