select date range from system
select * from
(select adddate('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) selected_date from
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3,
(select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v
where
((selected_date >= DATE_ADD(DATE_FORMAT(CURDATE() ,'%Y-%m-01'), INTERVAL - 1 MONTH) AND selected_date < DATE_ADD(CURDATE(), INTERVAL - 1 MONTH))
or
(selected_date >= DATE_FORMAT(CURDATE() ,'%Y-%m-01') AND selected_date < CURDATE()))
---select date or format date
DATE_FORMAT(DATE_ADD(rooms.created_at, INTERVAL + 7 HOUR),'%d-%m-%Y' ) date,
date(DATE_ADD(rooms.created_at, INTERVAL + 7 HOUR))
--template
DATE_FORMAT(DATE_ADD(&table.created_at, INTERVAL + 7 HOUR),'%d-%m-%Y' ) date,
date(DATE_ADD(&table.created_at, INTERVAL + 7 HOUR))