I’m trying to get a real life time based on seconds, where the number of seconds can be greater than 86400 (which equals 24 hours++). So for example; If the seconds equals 90000 the result will be 25:00:00, but instead I would like the output to be 01:00:00..
My logic is this:
IF seconds >= 86400 // Add day of date +1 // something similar to SEC_TO_TIME(seconds..). Need some help here else SEC_TO_TIME(seconds)
Advertisement
Answer
Using modulo:
sec_to_time(myvalue % 86400)
with t as (select 12 myvalue union all select 9000) select sec_to_time(myvalue % 86400) v from t
| v | | :------- | | 00:00:12 | | 02:30:00 |