日期:2014-05-16 浏览次数:20602 次
select v,case datepart(dw,v)
when 1 then '周日'
when 2 then '周一'
when 3 then '周二'
when 4 then '周三'
when 5 then '周四'
when 6 then '周五'
when 7 then '周六'
end d
from
(
select '2014-03-01' v union all
select '2014-03-02' v union all
select '2014-03-03' v union all
select '2014-03-04' v union all
select '2014-03-05' v union all
select '2014-03-06' v union all
select '2014-03-07' v union all
select '2014-03-08'
)t
where datepart(dw,v) in (2,3,4,5,6)
--周末
SELECT *
FROM ( SELECT DATEADD(dd, number, '2014-01-01') AS dd
FROM master..spt_values
WHERE type = 'P'
) A
WHERE DATEPART(dw, dd) IN ( 1, 7 )
--工作日
SELECT *
FROM ( SELECT DATEADD(dd, number, '2014-01-01') AS dd
FROM master..spt_values
WHERE type = 'P'
) A
WHERE DATEPART(dw, dd) not IN ( 1, 7 )