返回时间段内所有日期 天
select DATE_FORMAT(date_add('-06-01 00:00:00', interval row DAY),'%Y-%m-%d') date from( SELECT @row := @row + 1 as row FROM (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t,(select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t2, (SELECT @row:=-1) r) sewhere date_add('-06-01 00:00:00', interval row DAY) <= '-06-31 23:59:59'
返回时间段内所有日期 小时
select DATE_FORMAT(date_add('-06-01 00:00:00', interval row HOUR),'%Y-%m-%d %H') date from( SELECT @row := @row + 1 as row FROM (select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t,(select 0 union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) t2, (SELECT @row:=-1) r) sewhere date_add('-06-01 00:00:00', interval row HOUR) <= '-06-01 23:59:59';