码迷,mamicode.com
首页 > 其他好文 > 详细

日期函数

时间:2015-05-31 21:39:11      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

SELECT NOW();
+---------------------+
| NOW()               |
+---------------------+
| 2015-05-31 18:29:33 |
+---------------------+

SELECT DATE_HIRE, DATE_ADD(DATE_HIRE, INTERVAL 1 DAY), DATE_HIRE + 1 FROM EMPLOYEE_PAY_TBL;
+------------+-------------------------------------+---------------+
| DATE_HIRE  | DATE_ADD(DATE_HIRE, INTERVAL 1 DAY) | DATE_HIRE + 1 |
+------------+-------------------------------------+---------------+
| 2004-08-14 | 2004-08-15                          |      20040815 |
| 2006-07-22 | 2006-07-23                          |      20060723 |
| 1999-05-23 | 1999-05-24                          |      19990524 |
| 2007-06-28 | 2007-06-29                          |      20070629 |
| 2000-06-17 | 2000-06-18                          |      20000618 |
| 2001-01-14 | 2001-01-15                          |      20010115 |
+------------+-------------------------------------+---------------+

SELECT DAYNAME(DATE_HIRE) FROM EMPLOYEE_PAY_TBL;
+--------------------+
| DAYNAME(DATE_HIRE) |
+--------------------+
| Saturday           |
| Saturday           |
| Sunday             |
| Thursday           |
| Saturday           |
| Sunday             |
+--------------------+

SELECT DAYOFMONTH(DATE_HIRE) FROM EMPLOYEE_PAY_TBL;
+-----------------------+
| DAYOFMONTH(DATE_HIRE) |
+-----------------------+
|                    14 |
|                    22 |
|                    23 |
|                    28 |
|                    17 |
|                    14 |
+-----------------------+

SELECT DAYOFWEEK(DATE_HIRE) FROM EMPLOYEE_PAY_TBL;
+----------------------+
| DAYOFWEEK(DATE_HIRE) |
+----------------------+
|                    7 |
|                    7 |
|                    1 |
|                    5 |
|                    7 |
|                    1 |
+----------------------+

SELECT DAYOFYEAR(DATE_HIRE) FROM EMPLOYEE_PAY_TBL;
+----------------------+
| DAYOFYEAR(DATE_HIRE) |
+----------------------+
|                  227 |
|                  203 |
|                  143 |
|                  179 |
|                  169 |
|                   14 |
+----------------------+

 

日期函数

标签:

原文地址:http://www.cnblogs.com/fatoland/p/4542552.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!