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';
EOMONTH(StartDate, MonthToAdd)
Examples:
SELECT EOMONTH ( GETDATE() ) AS 'This Month';
SELECT EOMONTH ( GETDATE(), 1 ) AS 'Next Month';
SELECT EOMONTH ( GETDATE(), -1 ) AS 'Last Month';