select id = identity(int,0,1) into #t
from sysobjects --构造一个有自增列的表#T
declare @ny char(7)
set @ny = convert(char(4),datepart(year,getdate()))+'-'+
(case when datepart(month,getdate())<10 then '0'+convert(char(1),datepart(month,getdate())) else convert(char(2),datepart(month,getdate()))end)
-- select * from (
-- select rq =dateadd(d,id,@ny+'-01') from #t where ID BETWEEN 1 and datepart(day,getdate()) ) a
-- where datepart(dw,a.rq)=1 --列出求出本月是星期天的日期
--求出本月一至六的天数
select count(*) from (
select rq =dateadd(d,id,@ny+'-01') from #t where ID BETWEEN 1 and datepart(day,getdate()) ) a
where datepart(dw,a.rq)<>1
drop table #t
--注:datepart(dw,getdate())时,返回值为1时表示星期天.2,星期二,,依此类推.