我正在试图创建这个mysql程序,以制作一个包含今年所有日期和所有时间的表格(一小时间隔。)
CREATE TABLE FECHAS
(
created_at datetime
);
CREATE PROCEDURE filldates(dateStart DATE, dateEnd DATE)
BEGIN
WHILE dateStart <= dateEnd DO
INSERT INTO FECHAS (created_at) VALUES (dateStart);
SET dateStart = date_add(dateStart, INTERVAL 1 HOUR);
END WHILE;
END;//
CALL filldates('2015-01-01 00:00:00','2015-12-31 23:00:00');
但只有我明白了:
2015-01-01 00:00:00
2015-01-01 00:00:00
2015-01-01 00:00:00
2015-01-01 00:00:00
2015-01-01 00:00:00
我想这样做:
2015-01-01 00:00:00
2015-01-01 01:00:00
2015-01-01 02:00:00
2015-01-01 03:00:00
2015-01-01 04:00:00
2015-01-01 05:00:00
.....
2015-12-31 23:00:00