0
Good afternoon programmers, I have a problem in the trial where I need to print all the dates of the month, I created a loop until the day 31, but there is month that is less days that gives error, as check in the trial if the date is valid?
DELIMITER $$
CREATE PROCEDURE VisaoEvolucaoSemanal(dataIn date)
BEGIN
DECLARE dia decimal(2);
DECLARE mes varchar(10);
DECLARE ano varchar(10);
DECLARE media decimal(10,2);
DECLARE dataBusca date;
DECLARE datasaida date;
set dia = 00;
set mes = month (dataIn);
set ano = year(dataIn);
loop_data: LOOP
SET dia = dia + 01;
set datasaida = CONCAT(ano,'-',mes,'-',dia);
select datasaida;
IF dia > 31 THEN
LEAVE loop_data;
END IF;
END LOOP loop_data;
END$$
DELIMITER ;
What is your version of
MySQL
?– Sorack
Mysql version is 5.7.2
– Michel Diniz