开发者

how to get start date of the week using SQL Server 2008

开发者 https://www.devze.com 2023-01-03 00:42 出处:网络
I have another question, does any one know h开发者_开发知识库ow to get the start date and end date of the current week?

I have another question, does any one know h开发者_开发知识库ow to get the start date and end date of the current week?

Thanks very much.

Ling


DATEPART(dw, GETDATE()) will return the current day of week as an integer (Sunday=1, Saturday=7)

Simple math will take care of the rest.

  • Saturday: DATEADD(dd, 7 - DATEPART(dw, GETDATE()), GETDATE())
  • Sunday: DATEADD(dd, -1 * DATEPART(dw, GETDATE()), GETDATE())
0

精彩评论

暂无评论...
验证码 换一张
取 消