SQL如何通过当前日期获取上周一日期

 

--当前时间 
select getdate()
--当前时间周的起始日期(以周一为例)
select DATEADD(week,DATEDIFF(week,0,getdate()),0)
--上周起始:
select dateadd(week,-1,DATEADD(week,DATEDIFF(week,0,getdate()),0))
--上上周起始:
select dateadd(week,-2,DATEADD(week,DATEDIFF(week,0,getdate()),0))
--上上上周起始:s
elect dateadd(week,-3,DATEADD(week,DATEDIFF(week,0,getdate()),0))

 

你可能感兴趣的:(SQLSERVER)