DROP FUNCTION IF EXISTS secs_to_hrs;
create function secs_to_hrs (secs varchar(10))
return CONCAT_WS(' h ',lpad(secs/60 div 60,3,' ') ,
CONCAT(lpad(round(secs/60 mod 60),2,' '),' mins') );
What if I wanted to not display mins if they're 0?
In oracle I could possibly stick a decode in there.
I can probably break up the function into a few lines and make it work,
but curious if others had a one-liner addition that I could do.
|• one-liner perfectionist function question||Andrey Dmitriev||7 Nov|