日期:2014-05-17 浏览次数:20562 次
select number
,right(convert(varchar,case when year(dateadd(dd,(datepart(dw,dateadd(ww,(datepart(ww,cast(year(getdate()) as varchar)+'-1-1')-1)*-1, cast(year(getdate()) as varchar)+'-1-1'))-1)*-1
,dateadd(ww, (datepart(ww, cast(year(getdate()) as varchar)+'-1-1' )-number)*-1, cast(year(getdate()) as varchar)+'-1-1'))) < year(getdate())
then cast(year(getdate()) as varchar)+'-1-1'
else dateadd(dd,(datepart(dw,dateadd(ww,(datepart(ww,cast(year(getdate()) as varchar)+'-1-1')-1)*-1, cast(year(getdate()) as varchar)+'-1-1'))-1)*-1
,dateadd(ww, (datepart(ww, cast(year(getdate()) as varchar)+'-1-1' )-number)*-1, cast(year(getdate()) as varchar)+'-1-1'))
end,102),5) + '~' +
right(convert(varchar,case when year(dateadd(dd,(datepart(dw,dateadd(ww,(datepart(ww,cast(year(getdate()) as varchar)+'-1-1')-1)*-1, cast(year(getdate()) as varchar)+'-1-1'))-1)*-1
,dateadd(ww, (datepart(ww, cast(year(getdate()) as varchar)+'-1-1' )-number)*-1, cast(year(getdate()) as varchar)+'-1-1'))+6) > year(getdate())
then cast(year(getdate()) as varchar)+'-12-31'
else dateadd(dd,(datepart(dw,dateadd(ww,(datepart(ww,cast(year(getdate()) as varchar)+'-1-1')-1)*-1, cast(year(getdate()) as varchar)+'-1-1'))-1)*-1
,dateadd(ww, (datepart(ww, cast(year(getdate()) as varchar)+'-1-1' )-number)*-1, cast(year(getdate()) as varchar)+'-1-1'))+6
end,102),5) as date_between
from master..spt_values
where type='p'
and number < datepart(ww,cast(year(getdate()) as varchar)+'-12-31')+1
and number > 0
WITH tt
AS ( SELECT DATEPART(wk,
DATEADD(dd, m.number,
DATEADD(yy,
DATEDIFF(yy, 0, GETDATE()),
&