Here is a SP that will return a recordset containing the last day of each month:
CREATE Procedure uspLastDateOfMonths
AS
DECLARE @iCount tinyint
DECLARE @iMonth tinyint
DECLARE @StartDate datetime
DECLARE @LastDate datetime
CREATE TABLE #EndDates(MonthID tinyint, LastDayOfMonth char(10))
set @iCount=1
WHILE (@iCount <=12)
BEGIN
set @iMonth = @iCount
set @StartDate= str(@iMonth)+'/28/'+ltrim(str(year(getdate())))
set @LastDate= DATEADD(day, -1, DATEADD(month, 1, DATEADD(day,
(1-DATEPART(day,@StartDate)), @StartDate)))
insert #EndDates (MonthID, LastDayOfMonth) values (@iMonth,
convert(char(10), @LastDate, 101) )
set @iCount = @iCount +1
END
Select MonthID, LastDayOfMonth from #EndDates
Drop Table #EndDates