MySQL:将秒转换为天,分钟和小时 [英] MySQL: Convert seconds to days, minutes, and hours
本文介绍了MySQL:将秒转换为天,分钟和小时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
示例:
seonds ="1015557";
seonds ="1015557";
结果应为:
11days 18h:05m:57s
11days 18h:05m:57s
如何在MySQL中做到这一点?
How can do this in MySQL?
推荐答案
select concat(
format(floor(s / @day),0),
'days ',
time_format(sec_to_time(s % @day),'%Hh:%im:%ss')
) formatted_date
from (select 1015557 s) t, (select @day = 3600 * 24);
产生:
+--------------------+
| days |
+--------------------+
| 11days 18h:05m:57s |
+--------------------+
这篇关于MySQL:将秒转换为天,分钟和小时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文