If you work with financial data or have to do regular reporting type functions then I’m sure you currently use some kind of funky function/case statement to figure out what the last day of the month is and something even more funky to find the last day of next month or the month after.
SQL Server 2012 fixes that for you with the introduction of the EOMONTH function.
It’s very simple to use:
Even better, the EOMONTH function can accept an additional parameter where you can specify a number of months to add or remove to get relevant results:
SELECT EOMONTH('2012/03/16', -1)
It even handled the leap year correctly.
Simplicity itself. A great addition.