SQLSERVER——获取本月余下的日期

select dt,(Datepart(weekday,dt)-1) week
from (
select convert(varchar(10),dateadd(dd,number,convert(varchar(8),getdate(),120)+'01'),120) as dt
from master..spt_values 
where type='P' 
and dateadd(dd,number,convert(varchar(8),getdate(),120)+'01')<=dateadd(dd,-1,convert(varchar(8),dateadd(mm,1,getdate()),120)+'01') 
and number+1>=DatePart(dd,GETDATE())
)t
order by dt

 

 

参考文献:https://www.cnblogs.com/shenyixin/p/5511084.html

posted @ 2021-07-28 11:32  AaronLi  阅读(114)  评论(0编辑  收藏  举报