SQL 计算一个月有多少天
declare @Year varchar(10),@Month varchar(10)
set @Year=Convert(varchar,DATEPART(year,CONVERT(DATETIME,'2011-02-15')))
set @Month=Convert(varchar,DATEPART(month,CONVERT(DATETIME,'2011-02-15')))
select (DAY(dateadd(dd,-1,DATEADD(m,1,cast(@Year as varchar(4)) + '-' + cast(@Month as varchar(2)) + '-01'))))
下个月第一天,减一天