select top 366 id=identity(int,0,1)into # from syscolumns
select id,dateadd(day,id,'2007-01-01') r,month(dateadd(day,id,'2007-01-01')) m,
datepart(week,dateadd(day,id,'2007-01-01')) w,
datepart(q,dateadd(day,id,'2007-01-01')) q into #t
from # where year(dateadd(day,id,'2007-01-01'))=2007select count(distinct w)  季周
from #t
where q=datepart(q,'2007-07-31') and datediff(day,r,'2007-07-31')>=0select count(distinct w)  月周
from #t
where m=month('2007-07-31') and datediff(day,r,'2007-07-31')>=0
drop table #,#t