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.time;
	CREATE TEMPORARY TABLE tmp.time (dated DATE PRIMARY KEY) ENGINE = MEMORY;
	SET vCurrentDate = vStarted;
	WHILE vCurrentDate <= vEnded DO
		INSERT INTO tmp.time (dated) VALUES (vCurrentDate);
		SET vCurrentDate = DATE_ADD(vCurrentDate, INTERVAL 1 DAY);
	END WHILE;
    
END$$

DELIMITER ;