如何在 MySQL 查询中向 DATETIME 字段添加一天?

mysqlmysqli database更新于 2025/4/8 2:20:17

借助 DATE_ADD() 函数,我们可以向表的 DATETIME 字段添加一天。

mysql> Select StudentName, RegDate, Date_ADD(RegDate, INTERVAL +1 day) AS 'NEXT DAY'
       from testing where StudentName = 'gaurav';

+-------------+---------------------+---------------------+
| StudentName | RegDate             | NEXT DAY            |
+-------------+---------------------+---------------------+
| Gaurav      | 2017-10-29 08:48:33 | 2017-10-30 08:48:33 |
+-------------+---------------------+---------------------+
1 row in set (0.00 sec)

上述查询将在 MySQL 表 ‘testing’ 中将 StudentName 为 Gaurav 的 RegDate 添加一天。


相关文章


有用资源