Home >Database >Mysql Tutorial >mysql DAYOFMONTH,DAYOFYEAR,MONTH等函数应用实例

mysql DAYOFMONTH,DAYOFYEAR,MONTH等函数应用实例

WBOY
WBOYOriginal
2016-06-01 09:57:171659browse

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

<code class="language-sql">mysql> select DAYOFMONTH('1998-02-03'); 
-> 3</code>

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

<code class="language-sql">mysql> select DAYOFYEAR('1998-02-03'); 
-> 34</code>

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

<code class="language-sql">mysql> select MONTH('1998-02-03'); 
-> 2</code>

DAYNAME(date) 
返回date的星期名字。

<code class="language-sql">mysql> select DAYNAME("1998-02-05"); 
-> 'Thursday'</code>

MONTHNAME(date) 
返回date的月份名字。

<code class="language-sql">mysql> select MONTHNAME("1998-02-05"); 
-> 'February'</code>

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

<code class="language-sql">mysql> select QUARTER('98-04-01'); 
-> 2</code>

 

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