-- Return First and Last Date of a Month
DECLARE @Month smallint
SET @Month = 1
SELECT DAY(DATEADD(Month, DATEDIFF(Month, -1, getdate()) - 2, -1) + 1) as FirstDayofMonth,
DAY(DATEADD(Month, DATEDIFF(Month,0,getdate())+@Month, -1)) as LastDayOfMonth
If you wish to find out the Lastday of the previous month, just set @Month to 0.
Note: The value for @Month depends on the current month you are in. So if this month is September, the value of @Month is 1. Similarly for Oct(2), Nov(3), Dec(4), Jan(5), Feb(6) and so on.
Also read SQL Server: First and Last Sunday of Each Month