存储过程-创建日历

应用场景

  • 创建日历表数据

样例代码

delimiter //
DROP PROCEDURE IF EXISTS new_calendar //
CREATE PROCEDURE new_calendar(IN start_date DATE,end_date DATE)
BEGIN
DECLARE indexdate DATE;
DELETE FROM app_fd_vt_calendar;
SET indexdate=DATE(start_date);
WHILE indexdate<=DATE(end_date) DO
INSERT INTO app_fd_vt_calendar(id,dateCreated,dateModified) VALUES(indexdate,NOW(),NOW());
SET indexdate=ADDDATE(indexdate,1);
END WHILE;
END//
Create by Sean Fung on 2016-04-26 12:51:58.0
Last updated by Sean Fung on 2016-04-27 09:18:32.0