sql server 判断日期当前月有多少天

declare @tm datetime

set @tm = CONVERT(datetime,'2013-3-12')
declare @days int
select @days = case when MONTH(@tm) in(1,3,5,7,8,10,12) then 31 when MONTH(@tm) in(4,6,9,11) then 30 when MONTH(@tm) =2 and YEAR(@tm)%4 !=0 then 28 when MONTH(@tm) =2 and YEAR(@tm)%4 =0 then 29 else 0 end
select @days

posted @ 2014-01-16 18:57  singelMan  阅读(571)  评论(0编辑  收藏  举报