查询指定日期所在周的一周日班表记录

set datefirst 1 select count(*) from
(select date from(select dateadd(dd,number,'2015-01-01') date from master..spt_values where [type] = 'p' and number >= 0 and number < datediff(dd,'2015-01-01','2016-01-01')) t
where datepart(week,date) = (select DATENAME(week,@date))) a , bbreport b
where substring(b.date,1,10) = convert(char(10),a.date,120) and cmsid='014811'

你可能感兴趣的:(查询指定日期所在周的一周日班表记录)