SQL Server Date function: What is the day of the week?

Source: Internet
Author: User

"Pengcheng Wanli" published in www.sqlstudy.com

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.

This article by www.sqlstudy.com Original, All rights reserved, reprint please indicate the author and the source!

This article link: http://www.sqlstudy.com/sql_article.php?id=2008071601

SQL Server Date function: What is the day of the week?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.