SQL DATEPART(dw,date) need monday = 1 and sunday = 7

后端 未结 12 565
[愿得一人]
[愿得一人] 2020-12-23 16:27

I have a Query where I get the WeekDay of a date but by default:

  • Sunday = 1

  • Moday = 2

  • etc.

12条回答
  •  囚心锁ツ
    2020-12-23 17:09

    You can tell SQL Server to use Monday as the start of the week using DATEFIRST like this:

    SET DATEFIRST 1
    

提交回复
热议问题