摘要:
下文讲述MySQL数据库中获取指定时间数据中的分钟数的方法分享,如下所示;
实现思路:
使用SECOND(time)系统函数即可返回时间中的秒数信息
SECOND系统函数语法说明:
SECOND(time)
------参数说明----
time:时间数据或日期时间数据
------返回值说明-----
返回一个0~59的整型数据
注意事项:
输入一个非时间数据,则返回NULL
例:
mysql> select second('2020-9-5 11:33:65');
+-----------------------------+
| second('2020-9-5 11:33:65') |
+-----------------------------+
| NULL |
+-----------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> select second('2020-9-5 11:33:25');
+-----------------------------+
| second('2020-9-5 11:33:25') |
+-----------------------------+
| 25 |
+-----------------------------+
1 row in set (0.00 sec)
mysql> select second('11:33:25');
+--------------------+
| second('11:33:25') |
+--------------------+
| 25 |
+--------------------+
1 row in set (0.00 sec)
mysql> select second('2020-9-5 0:00:00');
+----------------------------+
| second('2020-9-5 0:00:00') |
+----------------------------+
| 0 |
+----------------------------+
1 row in set (0.00 sec)
mysql> select second('2020-9-5');
+--------------------+
| second('2020-9-5') |
+--------------------+
| 20 |
+--------------------+
1 row in set, 1 warning (0.00 sec)