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

周七以此类推
posted @ 2017-10-24 22:24  星火卓越  阅读(5178)  评论(0编辑  收藏  举报