First day Of this week and last week

后端 未结 3 1310
梦毁少年i
梦毁少年i 2021-02-06 16:42

I am currently getting first day Of this week and last week values with vbscript function in 2/12/2009 format. I was wondering if it was possible with SQL query.

3条回答
  •  失恋的感觉
    2021-02-06 17:49

    Ben's answer gives the wrong answer if today is Sunday. Regardless of whether the first day of the week is Sunday or Monday, the current date should be included in the current week. When I run his code for 3/24/2013, it gives me a ThisWeekStart of 3/25/2013. I used the following code instead: SELECT DATEADD(DAY, 1 - DATEPART(DW, '3/24/2013'), '3/24/2013')

提交回复
热议问题