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. This article will show you, How to use the SQL Server @@DATEFIRST with example. Before we get into the example, let us see the syntax behind this:
@@DATEFIRST in SQL Syntax
The basic syntax of SQL Server @@DATEFIRST is as shown below:
-- 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'
Thank You for Visiting Our Blog