700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > mysql查询时间段内所有日期 和 小时

mysql查询时间段内所有日期 和 小时

时间:2023-11-02 23:50:34

相关推荐

mysql查询时间段内所有日期 和 小时

返回时间段内所有日期 天

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';

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。