Mysql time conversion function usage _ PHP Tutorial

Source: Internet
Author: User
Mysql time conversion function usage. Mysql time conversion function usage 2007-10-3115: 03 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. Mys mysql time conversion function usage 2007-10-31 15: 03 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 (2007-10-31 );
-> 4

WEEKDAY (date)
Returns the week index of date (0 = Monday, 1 = Tuesday ,...... 6 = Sunday ).
Mysql> select WEEKDAY ('2017-10-31 13:05:00 ');
-> 2
Mysql> select WEEKDAY ('2017-10-31 ');
-> 2

DAYOFMONTH (date)
Returns the date of a month in the range of 1 to 31.
Mysql> select DAYOFMONTH ('2017-10-31 ');
-> 31

DAYOFYEAR (date)
Returns the number of days in a year from 1 to 366.
Mysql> select DAYOFYEAR ('2017-10-31 ');
-> 304


MONTH (date)
Returns the month of date, ranging from 1 to 12.
Mysql> select MONTH ('2017-10-31 ');
-> 10

DAYNAME (date)
Returns the week name of date.
Mysql> select DAYNAME ("2007-10-31 ");
-> 'Wednesday'

MONTHNAME (date)
Returns the month name of date.
Mysql> select MONTHNAME ("2007-10-31 ");
-> 'October'

QUARTER (date)
Returns the quarter of a year from date, ranging from 1 to 4.
Mysql> select QUARTER ('2017-10-31 ');
-> 4

WEEK (date)
 
WEEK (date, first)
If Sunday is the first day of a week, there is a single parameter that returns the number of weeks of the date, ranging from 0 to 52. Two parameter formats: WEEK () allows you to specify whether the WEEK starts on Sunday or Monday. If the second parameter is 0, the week starts from Sunday, and if the second parameter is 1, it starts from Monday.
Mysql> select WEEK ('2017-02-20 ');
-> 7
Mysql> select WEEK ('2017-02-20 ', 0 );
-> 7
Mysql> select WEEK ('2017-02-20 ', 1 );
-> 8

YEAR (date)
Returns the year of date, ranging from 1000 to 9999.
Mysql> select YEAR ('98-02-03 ');
-> 1998

HOUR (time)
Returns the hour of time, ranging from 0 to 23.
Mysql> select HOUR ('10: 05: 03 ');
-> 10

MINUTE (time)
Returns the minute of time, ranging from 0 to 59.
Mysql> select MINUTE ('98-02-03 10:05:03 ');
-> 5

SECOND (time)
The number of seconds for the return time, ranging from 0 to 59.
Mysql> select SECOND ('10: 05: 03 ');
-> 3

PERIOD_ADD (P, N)
Add N months to phase P (in the format of YYMM or YYYYMM ). Return value in the format of YYYYMM. Note that the phase parameter P is not a date value.

  • 5 pages in total:
  • Previous Page
  • 1
  • 2
  • 3
  • 4
  • 5
  • Next page

Http://www.bkjia.com/PHPjc/364003.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/364003.htmlTechArticlemysql time conversion function usage 15: 03 DAYOFWEEK (date) returns the week index of date (1 = Sunday, 2 = Monday, 7 = Saturday ). These index values correspond to the ODBC standard. Mys...

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.