Convert seconds to hh:mm:ss

If always less than 24 hours, you could use millis_to_str, e.g. 120 seconds:

SELECT millis_to_str(120*1000-3600000,"%T");

  • Convert to milliseconds (*1000)
  • Subtract the base Epoch time (1 hour)
  • Print only the time component

If you’re looking for a general “any number of seconds to hours:minutes:seconds” function then no, there isn’t one and you’d have to do the division yourself. (Likely write your own UDF to do it.)

2 Likes