Obtain week for mysqlDAYOFWEEK and WEEKDAY

Source: Internet
Author: User
In mysql, we can use the DAYOFWEEK and WEEKDAY functions to obtain the week of the specified date. The difference is that the weekly index obtained by DAYOFWEEK starts with 1, and the weekly index obtained by WEEKDAY starts with 0. DAYOFWEEK (date)
Returns the index of the week of the date (1 = Sunday, 2 = Monday ,...... 7 = Saturday ). These index values correspond to the ODBC standard.

Mysql> select DAYOFWEEK ('2017-02-03 ');-> 3

WEEKDAY (date)
Returns the week index of date (0 = Monday, 1 = Tuesday ,...... 6 = Sunday ).

Mysql> select WEEKDAY ('2017-10-04 22:23:00 ');-> 5 mysql> select WEEKDAY ('2017-11-05');-> 2

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.