List:General Discussion« Previous MessageNext Message »
From:Andrey Dmitriev Date:November 7 2007 5:13pm
Subject:one-liner perfectionist function question
View as plain text  
DROP FUNCTION IF EXISTS secs_to_hrs;
DELIMITER |
create function secs_to_hrs (secs varchar(10))
returns varchar(13)
DETERMINISTIC
BEGIN
return  CONCAT_WS(' h ',lpad(secs/60 div 60,3,' ') , 
CONCAT(lpad(round(secs/60 mod 60),2,' '),' mins') );
END;
|
DELIMITER ;


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.

Thread
one-liner perfectionist function questionAndrey Dmitriev7 Nov