PHP开发教程

MySQL adddate()函数

adddate(date,INTERVAL expr unit), adddate(expr,days)

当第二个参数INTERVAL形式调用, ADDDATE() 是DATE_ADD() 的同义词。相关函数SUBDATE() 是 DATE_SUB()的同义词。有关INTERVAL单位参数信息,请参阅DATE_ADD()的相关讨论。

mysql> SELECT DATE_ADD('1998-01-02', INTERVAL 31 DAY);
+---------------------------------------------------------+
| DATE_ADD('1998-01-02', INTERVAL 31 DAY)                 |
+---------------------------------------------------------+
| 1998-02-02                                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)

mysql> SELECT ADDDATE('1998-01-02', INTERVAL 31 DAY);
+---------------------------------------------------------+
| ADDDATE('1998-01-02', INTERVAL 31 DAY)                  |
+---------------------------------------------------------+
| 1998-02-02                                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)

当第二个参数的使用天的形式调用,MySQL将其视为被添加天的整数到expr。

mysql> SELECT ADDDATE('1998-01-02', 31);
+---------------------------------------------------------+
| DATE_ADD('1998-01-02', INTERVAL 31 DAY)                 |
+---------------------------------------------------------+
| 1998-02-02                                              |
+---------------------------------------------------------+
1 row in set (0.00 sec)


Powered by PHP二次开发 ©2008-2017