USE `util`; DROP procedure IF EXISTS `time_createTable`; DELIMITER $$ USE `util`$$ CREATE DEFINER=`root`@`%` PROCEDURE `time_createTable`(vStarted DATE, vEnded DATE) BEGIN DECLARE vCurrentDate DATE; DROP TEMPORARY TABLE IF EXISTS tmp.tTime; CREATE TEMPORARY TABLE tmp.tTime (dated DATE PRIMARY KEY); SET vCurrentDate = vStarted; WHILE vCurrentDate <= vEnded DO INSERT INTO tmp.tTime (dated) VALUES (vCurrentDate); SET vCurrentDate = DATE_ADD(vCurrentDate, INTERVAL 1 DAY); END WHILE; END$$ DELIMITER ;