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

首页 / 新闻资讯 / 正文

借助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)

以上查询将在RegDate中添加一天,其中MySQL表名为“ testing”的StudentName是Gaurav。