To get the day of the week, you need to use the DATE function in SQL Server: Datename ().
Today is the day of the week, Example 1:
Set Language N ' 中文版 ' select Datename (Weekday, GETDATE ())
Wednesday
Today is the day of the week, Example 2:
Set Language N ' Simplified Chinese ' select Datename (Weekday, GETDATE ())
Wednesday
Today is the day of the week, example 3:
Set Datefirst 1select datepart (Weekday, GETDATE ())
3 --Wednesday
Note: Another SQL Server date function, datepart (), is used here. "Set Datefirst 1" indicates that the first day of the week is set to Monday. In Old America, their first day of the week was accustomed to Sunday. We can get the Datefirst setting value of the current session through the @ @datefirst function.
SELECT @ @datefirst
1
You may have a question: Where did the language parameters after "set Language" Get? Can I get the day of the week in other countries ' languages? Of course it is, please look at the following:
Select Alias, * from Master. Syslanguages
If I want to get the day of the week in Korean, you can:
Set Language N ' Korean ' select Datename (Weekday, GETDATE ())
For detailed usage of date functions in SQL Server: Datename (), see the SQL Server Help documentation.
SQL Server Date function: What is the day of the week?