The SET DATEFIRST function is used to set the first day of the week from number 1-7. In order to know the current first day of the week, @@DATEFIRST is used. … The DATEFIRST settings effects the day of the week value for a date value returned from the DATEPART function.
What is @@ Datefirst in SQL Server?
The @@DATEFIRST in SQL Server is one of the Date and Time Function, which will return the first day of the week. This value is between 1 and 7. If your default language is US English, then by default, 7 is returned.
How do I use Datefirst in SQL?
To see the current setting of SET DATEFIRST, use the @@DATEFIRST function. The setting of SET DATEFIRST is set at execute or run time and not at parse time. Specifying SET DATEFIRST has no effect on DATEDIFF. DATEDIFF always uses Sunday as the first day of the week to ensure the function is deterministic.