获取当月总天数:DECLARE @YEAR_MONTH varchar(6)SET @YEAR_MONTH = '200702'SELECT DAY(DATEADD(MM, 1, CONVERT(DATETIME, @YEAR_MONTH + '01', 112)) - DAY(CONVERT(DATETIME, @YEAR_MONTH + '01', 112)))
获取每一月最后一天select day(cast('2002-3-1' as datetime)-1)