DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`firstDayOfMonth`(vDate DATE) RETURNS date DETERMINISTIC NO SQL BEGIN /** * Returns the date formatted to the first day of month. * * @param vDate The date to format * @return The formatted date */ RETURN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) ; END$$ DELIMITER ;