What is @@DATEFIRST
it is one of the configuration functions returns first day of the week (tinyint) . The U.S. English default is 7, Sunday
- The language setting affects the interpretation of character strings as they are converted to date values for storage in the database, and the display of date values that are stored in the database.
- This setting does not affect the storage format of date data.
Where it is used ?
Is an integer that indicates the first day of the week. It can be one of the following values.
|Value||First day of the week is|
|7 (default, U.S. English)||Sunday|
It may be confusing how can Saturday and Sunday have the same value !
well lets explain that little bit more, according to the above datefirst value Sunday is considered as first day of the week so SUNDAY -1,MONDAY-2,……..SATURDAY-7
As we just mentioned value of the @@datefirst varies according to the language setting
Lets change the value of the DATEFIRST and see what happens when we use the DATEPART