Calculating Last Day of Month For Any Given Date Has become more easy as EOMONTH (End Of Month) function has been introduced in SQL Server Denali (MSSQL 2011).
How ? See Following
EOMONTH ( start_date [, month_to_add ] )
Month_to_Add : This is Optional Parameter.
Select GetDate()As InputDate,EOMONTH (GETDATE()) As Result
How to Find Last Day Of Previous Month
Select GetDate()As InputDate,EOMONTH (GETDATE(),-1) As Result
So You Just Need To Add Optional Parameter Number_of_Month So To Get Previous Month Last Date I have Added –1 To Optional Parameter. To Get Desired Month Last Date You Can Pass No_Of_Month Parameter.
See Following Screen Shot