摘要:
下文讲述MySQL数据库计算出一个秒数所对应的小时数分钟数的方法分享,如下所示;
实现思路:
使用SEC_TO_TIME函数即可返回秒数所对应的时间信息
SEC_TO_TIME语法:
SEC_TO_TIME(seconds)
--------参数说明-----
seconds:
秒数
---------返回值说明-----
返回一个HH:MM:SS或HHMMSS格式的小时分钟信息
例:
mysql> select sec_to_time('a');
+------------------+
| sec_to_time('a') |
+------------------+
| 00:00:00 |
+------------------+
1 row in set, 1 warning (0.00 sec)
mysql> select sec_to_time('-121');
+---------------------+
| sec_to_time('-121') |
+---------------------+
| -00:02:01 |
+---------------------+
1 row in set (0.00 sec)
mysql> select sec_to_time('121');
+--------------------+
| sec