Monday, December 22, 2014

Get End Of Month in SQL Query

There is in built function of SQL is available to get the End of the Month Date.

EOMONTH(StartDate, MonthToAdd)



Examples:

SELECT EOMONTH ( GETDATE() ) AS 'This Month';
SELECT EOMONTH ( GETDATE(), 1 ) AS 'Next Month';
SELECT EOMONTH ( GETDATE(), -1 ) AS 'Last Month';