Quantcast
Channel: MySQL Forums - MySQL Workbench
Viewing all articles
Browse latest Browse all 3739

Help with the Routine (no replies)

$
0
0
Hi All,
I am creating a routine to populate dates . My SQL date function are not working in the routine
INSERT INTO Dates VALUES (i,LoopDate,YEAR(LoopDate),DAY(LoopDate));
For this insert the date value is "00:00:0000"

Please help , why is the date function not working . Have i set the value of date variable right.

DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `new_routine`()
BEGIN
DECLARE StartDate date;
DECLARE EndDate date;
DECLARE LoopDate date ;
DECLARE i int ;
SET i =2;
SET StartDate = '01/01/2009';
SET EndDate = '31/12/2020' ;
SET LoopDate = StartDate;
iterloop: LOOP

IF LoopDate < '31/12/2020'THEN
INSERT INTO Dates VALUES (i,LoopDate,YEAR(LoopDate),DAY(LoopDate));


SET LoopDate = ADDDATE(LoopDate, 1);
SET i =i+1;
ELSE
LEAVE iterloop;
END IF;
END LOOP iterloop;
END

Viewing all articles
Browse latest Browse all 3739

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>