永不言弃!
不忘初心:感恩的心!上进的心!

sql 语句

select number+1 as wknum,dateadd(wk,number,'2017-01-01') as firstday,
(case when year(dateadd(d,-1,dateadd(wk,number+1,'2017-01-01')))>2017 then '2017-12-31' 
else dateadd(d,-1,dateadd(wk,number+1,'2017-01-01')) end) as sevenday
from master..spt_values
where type='p' and year(dateadd(wk,number,'2017-01-01'))=2017

结果如图

 

 

 

本文引自:http://www.myexception.cn/sql-server/327685_3.html

 

posted on 2017-11-01 15:56  永不言弃!  阅读(641)  评论(0编辑  收藏  举报