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))

 

转载于:https://www.cnblogs.com/qiangshu/p/8552054.html

你可能感兴趣的:(SQL如何通过当前日期获取上周一日期【转】)