sql如何通过当前日期获取上周,上上周,上上上周的起始日期(周一_周七)

当前时间周的起始日期(以周一为例)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))
上上上周起始:select dateadd(week,-3,DATEADD(week,DATEDIFF(week,0,getdate()),0)) 周七以此类推
上一篇:快手4-5月Java岗面经


下一篇:Oracle中为表设置自动增长的标识列