SqlServer 取某个月的每一天

declare @ksrq datetime
set @ksrq='2011-2-1'

select dateadd(d,a.number,@ksrq) as fDate
from master..spt_values a where type = 'P'
and dateadd(d,a.number,@ksrq) >= convert(varchar(7),@ksrq,120)+'-01'
and dateadd(d,a.number,@ksrq) < convert(varchar(7),dateadd(mm,1,@ksrq),120)+'-01'

转载于:https://www.cnblogs.com/zhang5254/archive/2012/09/24/SqlServer.html

你可能感兴趣的:(SqlServer 取某个月的每一天)