SET GLOBAL LOG_BIN_TRUST_FUNCTION_CREATORS = 1;
DELIMITER $$
CREATE FUNCTION f_num_notas (vData DATE)
RETURNS INT
BEGIN
DECLARE NUMNOTAS INT DEFAULT 0;
SELECT COUNT(*) INTO NUMNOTAS FROM NOTAS WHERE DATA_VENDA = vData;
RETURN NUMNOTAS;
END $$
DELIMITER ;
SELECT f_num_notas("2017-01-01");