select DATE_FORMAT(date_add('2022-06-01 00:00:00',intervalrowDAY),'%Y-%m-%d')datefrom(SELECT@row :=@row+1asrowFROM(select0unionallselect1unionallselect2unionallselect3unionallselect4unionallselect5unionallselect6unionallselect7unionallselect8unionallselect9) t,(select0unionallselect1unionallselect2unionallselect3unionallselect4unionallselect5unionallselect6unionallselect7unionallselect8unionallselect9) t2,(SELECT@row:=-1) r
) se
where date_add('2022-06-01 00:00:00',intervalrowDAY)<='2022-06-31 23:59:59'
返回时间段内所有日期 小时
select DATE_FORMAT(date_add('2022-06-01 00:00:00',intervalrowHOUR),'%Y-%m-%d %H')datefrom(SELECT@row :=@row+1asrowFROM(select0unionallselect1unionallselect2unionallselect3unionallselect4unionallselect5unionallselect6unionallselect7unionallselect8unionallselect9) t,(select0unionallselect1unionallselect2unionallselect3unionallselect4unionallselect5unionallselect6unionallselect7unionallselect8unionallselect9) t2,(SELECT@row:=-1) r
) se
where date_add('2022-06-01 00:00:00',intervalrowHOUR)<='2022-06-01 23:59:59';