This Microsoft SQL script figures out what the last day of the month is (28, 30, or 31) so that you don't have to recite the "30 days has September, April, May, and November..." poem or do the "knuckle trick."
DECLARE @Date DATETIME SET @Date = '1/1/2006' SELECT DAY(DATEADD(d, -DAY(DATEADD(m,1,@Date)),DATEADD(m,1,@Date))) AS LastDayOfMonth