CREATE OR ALTER FUNCTION FORMATTIME_EXT (
    CAMPO TIMESTAMP)
RETURNS VARCHAR(20)
AS
BEGIN
 RETURN (
            lpad(EXTRACT(hour   FROM Campo) ,2,'0') ||':'||
            lpad(EXTRACT(minute FROM Campo) ,2,'0') ||':'||
            lpad(REPLACE(EXTRACT(second FROM Campo),'.','') ,2,'0')
        );
END

CREATE OR ALTER FUNCTION FORMATTIME (
    CAMPO TIMESTAMP)
RETURNS VARCHAR(16)
AS
BEGIN
 RETURN (
            lpad(EXTRACT(hour   FROM Campo) ,2,'0') ||':'||
            lpad(EXTRACT(minute FROM Campo) ,2,'0')
        );
END;