Usage of MySQL time conversion function

Source: Internet
Author: User

Usage of MySQL time conversion function

Returns the week index of date (1= Sunday, 2 = Monday, ...). 7= Saturday). These index values correspond to ODBC standards.

mysql> select DAYOFWEEK(2007-10-31);
-> 4
WEEKDAY(date)

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

mysql> select WEEKDAY('2007-10-31 13:05:00');
-> 2
mysql> select WEEKDAY('2007-10-31');
-> 2
DAYOFMONTH(date)

Returns the date in the month of date, in the range 1 through 31.

mysql> select DAYOFMONTH('2007-10-31');
-> 31
DAYOFYEAR(date)

Returns the number of days in a year, in the range of 1 to 366.

mysql> select DAYOFYEAR('2007-10-31');
-> 304
MONTH(date)

Returns the month of date, ranging from 1 to 12.

mysql> select MONTH('2007-10-31');
-> 10
DAYNAME(date)

Returns the name of the week of date.

mysql> select DAYNAME("2007-10-31");
-> 'Wednesday'
MONTHNAME(date)

Returns the month name of the date.

mysql> select MONTHNAME("2007-10-31");
-> 'October'
QUARTER(date)

Returns the quarter of date one year, ranging from 1 to 4.

mysql> select QUARTER('2007-10-31');
-> 4
WEEK(date)
WEEK(date,first)

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.