SELECT DATEPART(weekday, CAST('20051004' AS DATETIME) + @@DATEFIRST); : DATEFIRST « Date Functions « SQL Server / T-SQL Tutorial






6> SELECT DATEPART(weekday, CAST('20051004' AS DATETIME) + @@DATEFIRST);
7> GO

-----------
          3

-----------
          3
1>








10.5.DATEFIRST
10.5.1.To change the first day value, you can use the SET DATEFIRST command.
10.5.2.Using SQL Server's First Day of the Week Setting
10.5.3.SELECT DATEPART(weekday, CAST('20051004' AS DATETIME) + @@DATEFIRST);