DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`midnight`() RETURNS datetime DETERMINISTIC READS SQL DATA BEGIN RETURN TIMESTAMP(util.VN_CURDATE(), '23:59:59'); END$$ DELIMITER ;