Monday, April 18, 2005

Month Variable Table

Every once in a while you need a quick Table w/ a range of dates, that's what this is for...


Declare @iLoop AS INT
SET @iLoop = 0
DECLARE @rptMonths TABLE(rptMonth DateTime)
WHILE @iLoop <= DateDiff(mm, @StartDate, @EndDate)
BEGIN
INSERT INTO @rptMonths(rptMonth) VALUES(DATEADD(mm, @iLoop, @StartDate))
SET @iLoop = @iLoop + 1
END

No comments:

Post a Comment