Home >Database >Mysql Tutorial >mysql 时间转换函数的用法_MySQL

mysql 时间转换函数的用法_MySQL

WBOY
WBOYOriginal
2016-06-01 13:53:30826browse

  mysql 时间转换函数的用法2007-10-31 15:03DAYOFWEEK(date) 

  返回日期date的星期索引(1=星期天,2=星期一, ……7=星期六)。这些索引值对应于ODBC标准。 

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

  返回date的星期索引(0=星期一,1=星期二, ……6= 星期天)。 

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

  返回date的月份中日期,在1到31范围内。 

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

  返回date在一年中的日数, 在1到366范围内。 

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

  返回date的月份,范围1到12。 

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

  返回date的星期名字。 

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

  返回date的月份名字。 

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

  返回date一年中的季度,范围1到4。 

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn