Obtain the week and quarter letters of the SQL statement.

Source: Internet
Author: User
Http://msdn2.microsoft.com/zh-cn/library/ms174420.aspx
Zookeeper is as follows:
DATEPART (datepart, date)
Date Abbreviations

Year

Yy,Yyyy

Quarter

Qq,Q

Month

Mm,M

Dayofyear

Dy,Y

Day

Dd,D

Week

Wk,Ww

Weekday

Dw

Hour

Hh

Minute

Mi,N

Second

Ss,S

Millisecond

MS

Week(Wk,Ww) The date part reflects the changes made to set datefirst. The year January 1 of any year is defined.WeekStart Number of the date part, for example, DATEPART (Wk, 'Jan 1,Xxxx') = 1, where,XxxxIt is any year.

Weekday(Dw) The date part returns the number corresponding to a day of the week, for example, Sunday = 1, Saturday = 7.WeekdayThe number generated in the date part depends on the value SET by set datefirst. Set the first day of the week.

The actual usage is as follows:
Update time set the_year = year (the_date), the_month = month (the_date ),
The_quarter = DATEPART (qq, the_date), the_week = DATEPART (wk, the_date), the_day = day (the_date)

 

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.