如何从MySQL列中的所有日期记录中减去秒?
让我们首先创建一个表-
mysql> create table DemoTable833(ArrivalTime datetime);
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable833 values('2019-01-10 12:40:50'); mysql> insert into DemoTable833 values('2019-02-16 11:10:30'); mysql> insert into DemoTable833 values('2018-03-17 10:00:10');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable833;
这将产生以下输出-
+---------------------+ | ArrivalTime | +---------------------+ | 2019-01-10 12:40:50 | | 2019-02-16 11:10:30 | | 2018-03-17 10:00:10 | +---------------------+ 3 rows in set (0.00 sec)
以下是从MySQL日期减去秒的查询-
mysql> select ArrivalTime-interval 10 SECOND from DemoTable833;
这将产生以下输出-
+--------------------------------+ | ArrivalTime-interval 10 SECOND | +--------------------------------+ | 2019-01-10 12:40:40 | | 2019-02-16 11:10:20 | | 2018-03-17 10:00:00 | +--------------------------------+ 3 rows in set (0.00 sec)