DROP procedure IF EXISTS `vn`.`rangeDateInfo`; DELIMITER $$ CREATE PROCEDURE `vn`.`rangeDateInfo` (vStarted DATE, vEnded DATE) BEGIN /* * Crea una tabla temporal con las fechas * desde una fecha inicial a una final * @vStarted: fecha inicial * @vEnded: fecha final */ DECLARE vDated DATE DEFAULT vStarted; DROP TEMPORARY TABLE IF EXISTS tmp.rangeDate; CREATE TEMPORARY TABLE tmp.rangeDate( dated DATE ) ENGINE = MEMORY; WHILE vDated <= vEnded DO INSERT INTO tmp.rangeDate(dated) VALUES(vDated); SET vDated = DATE_ADD(vDated, INTERVAL 1 DAY); END WHILE; END$$ DELIMITER ;