从MySQL日期时间中删除秒?
要从MySQL日期时间中删除秒,请按照以下语法使用UPDATE和SET-
update yourTableName set yourDateColumnName=yourDateColumnName -second(yourDateColumnName);
让我们首先创建一个表-
mysql> create table DemoTable-> (
-> Shippingdatetime datetime
-> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values('2019-01-21 12:05:20');mysql> insert into DemoTable values('2019-03-01 10:23:35');
mysql> insert into DemoTable values('2019-06-09 11:00:56');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
输出结果
+---------------------+| Shippingdatetime |
+---------------------+
| 2019-01-21 12:05:20 |
| 2019-03-01 10:23:35 |
| 2019-06-09 11:00:56 |
+---------------------+
3 rows in set (0.00 sec)
这是从MySQL日期时间中删除秒的查询-
mysql> update DemoTable set Shippingdatetime=Shippingdatetime-second(Shippingdatetime);Rows matched: 3 Changed: 3 Warnings: 0
让我们再次检查表中的所有记录-
mysql> select *from DemoTable;
输出结果
+---------------------+| Shippingdatetime |
+---------------------+
| 2019-01-21 12:05:00 |
| 2019-03-01 10:23:00 |
| 2019-06-09 11:00:00 |
+---------------------+
3 rows in set (0.00 sec)
以上是 从MySQL日期时间中删除秒? 的全部内容, 来源链接: utcz.com/z/322366.html