I did a trigger to count the weekdays. It accepts the dates of month 06 very well, but other dates gives the following error:
INSERT INTO 'teste' VALUES ("2018-05-01")
#1292 - Incorrect date value: '20180532' for column 'i' at row 1
Trigger code:
BEGIN
DECLARE i date;
DECLARE j int;
SET i = DATE(NEW.dataAntiga);
SET j = 0;
WHILE (date(i) < NOW()) DO
if WEEKDAY(date(i)) != 5 AND WEEKDAY(date(i)) != 6 THEN
SET j = j + 1;
END IF;
SET i = date(i)+1;
END WHILE;
insert into teste2 values (j);
END
test2table: