Skip to content

Instantly share code, notes, and snippets.

@eminetto
Created June 29, 2012 14:10
Show Gist options
  • Save eminetto/3018177 to your computer and use it in GitHub Desktop.
Save eminetto/3018177 to your computer and use it in GitHub Desktop.
make dates
delimiter $$
drop procedure if exists make_dates $$
CREATE PROCEDURE make_dates( max_recs int)
begin
declare start_dt datetime;
declare numrecs int default 1;
set start_dt = date_format( now() - interval max_recs minute, '%Y-%m-%d %H:%i:00');
insert into Couvert (user_id, date, value, created) values (1, start_dt, 3.9, now() );
while numrecs < max_recs
do
insert into Couvert (user_id, date, value, created)
select 1, date + interval ( numrecs ) day,3.9, now()
from Couvert;
select count(*) into numrecs from Couvert;
select numrecs;
end while;
end $$
delimiter ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment