欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

addtime(expr1,expr2)

shiping1 的头像

addtime(expr1,expr2)

ADDTIME() 添加到expr2 到 expr1 并返回结果。 expr1 是一个时间或日期时间表达式,expr2是一个时间表达式。

这里 '1 1:1:1.000002'  表示加一天再带1小时1分1.000002
如果没有空格 即 11:1:1.000002 表示加11小时1分1.000002
mysql> SELECT ADDTIME('1997-12-31 23:59:59.999999','1 1:1:1.000002');
+---------------------------------------------------------+
| DATE_ADD('1997-12-31 23:59:59.999999','1 1:1:1.000002') |
+---------------------------------------------------------+
| 1998-01-02 01:01:01.000001                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)

来自 http://www.yiibai.com/mysql/mysql_function_addtime.html


The following statement will return a time after adding 2 days 1 hr. 39 min. and 27.50 sec. with the datetime 2008-05-15 13:20:32.50.

  1. SELECT ADDTIME('2008-05-15 13:20:32.50','2 1:39:27.50'as required_datetime;  

Output

mysql> SELECT ADDTIME('2008-05-15 13:20:32.50','2 1:39:27.50') as required_datetime;
+----------------------------+
| required_datetime          |
+----------------------------+
| 2008-05-17 15:00:00.000000 | 
+----------------------------+
1 row in set (0.00 sec)
来自 http://www.w3resource.com/mysql/date-and-time-functions/mysql-addtime-function.php
普通分类: