select cal_date,
DATE_FORMAT(DATE_SUB(cal_date, INTERVAL 1 DAY), '%Y-%m-%d 17:00:00') AS start_date ,
DATE_FORMAT(DATE_ADD(cal_date, INTERVAL 0 DAY), '%Y-%m-%d 17:00:00') AS end_date
from t_calendar t
where 1=1
and t.cal_date >= #{dto.startDate}
and t.cal_date <= #{dto.endDate}
order by cal_date desc
select cal_date,
DATE_FORMAT(DATE_SUB(cal_date, INTERVAL 1 DAY), '%Y-%m-%d 17:00:00') AS start_date ,
DATE_FORMAT(DATE_ADD(cal_date, INTERVAL 0 DAY), '%Y-%m-%d 17:00:00') AS end_date
from t_calendar where cal_date >= (
SELECT DATE_FORMAT(MIN(create_time), '%Y-%m-%d 00:00:00') AS min_create_time
FROM t_order
) and cal_date <=DATE_FORMAT(NOW(), '%Y-%m-%d 00:00:00')
order by cal_date desc