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.
The basic syntax of SQL Server @@DATEFIRST is
@@DATEFIRST
@@DATEFIRST in SQL Example
In this Date and Time Function example, we will show how to use this @@DATEFIRST. To understand this better, we are using the SET DATEFIRST function in SQL Server to alter the First day of a week.
-- It will Return the Default first Day SELECT @@DATEFIRST AS 'First day of the Week' -- Set the DateFirst Value to 2 (Tuesday) SET DATEFIRST 2; -- Now let me select the first Day Value SELECT @@DATEFIRST AS 'First day of the Week' SELECT GETDATE() AS 'Today', DATEPART(dw, GETDATE()) AS 'Today Number'