Take the date 2017-12-11 (Monday) as an example
one or one-like usage
Select DATEPART (Weekday, ' 2017-12-11 ')
Results: 2
Description: Due to MS SQL default Sunday is the 1th day of one weeks, so 2017-12-11 Monday on the 2nd day of one weeks. So analogy: 1. 7 represents the Sunday. Saturday
Ii. setting Monday as the 1th day of one weeks
Set Datefirst 1 -This sentence will be set in Monday for the 1th day of one weeks.
Select DATEPART (Weekday, ' 2017-12-11 ')
Results: 1
Description: Set Datefirst 1 can be set to Monday one weeks on the 1th day, so 2017-12-11 Monday on the 1th day of one weeks. So analogy: 1. 7 represents the Monday. Sunday.
three, the use of SET Datefirst
Syntax: SET datefirst {number | @number_var}
Parameters
Number | @number_var
indicates an integer for the first day of the week. Can be one of the following values.
The first day of the week is &NBSP
1 week
2 Tuesday
3 week three
4 week four
5 Friday
6 Saturday < br> 7 Week day (default, U.S. English)
Description:
To view the current settings of the set Datefirst, use the @ @DATEFIRST function. The settings for the
set Datefirst are set at execution or Run-time, not at parse time.