sql >> Base de Datos >  >> RDS >> Mysql

Convertir segundos a días, horas, minutos, segundos (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);

produce:

+--------------------+                                                                                                                               
| days               |                                                                                                                               
+--------------------+                                                                                                                               
| 11days 18h:05m:57s |                                                                                                                               
+--------------------+