MySQL Datetime添加天数?
让我们首先创建一个表-
mysql> create table DemoTable1871
(
ArrivalDate datetime
);使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1871 values('2019-12-19 7:45:00');
mysql> insert into DemoTable1871 values('2018-11-10 12:00:00');
mysql> insert into DemoTable1871 values('2019-01-31');使用select语句显示表中的所有记录-
mysql> select * from DemoTable1871;
这将产生以下输出-
+---------------------+ | ArrivalDate | +---------------------+ | 2019-12-19 07:45:00 | | 2018-11-10 12:00:00 | | 2019-01-31 00:00:00 | +---------------------+ 3 rows in set (0.00 sec)
这是添加天数的查询-
mysql> update DemoTable1871 set ArrivalDate=date_add(ArrivalDate, interval 6 day); Rows matched: 3 Changed: 3 Warnings: 0
让我们再次检查表记录-
mysql> select * from DemoTable1871;
这将产生以下输出-
+---------------------+ | ArrivalDate | +---------------------+ | 2019-12-25 07:45:00 | | 2018-11-16 12:00:00 | | 2019-02-06 00:00:00 | +---------------------+ 3 rows in set (0.00 sec)
热门推荐
10 生日祝福语简短搞笑女儿
11 2026猪年祝福语简短语
12 项目建设春节祝福语简短
13 兔年祝福语简短100字
14 诗意新婚祝福语高级简短
15 生日寿宴祝福语简短精辟
16 哥哥祝福语简短霸气句子
17 婚礼祝福语简短情话文案
18 同学分开祝福语简短