DB
[MySQL] 한 주(일주일)의 데이터 가져오기
애용쓰
2022. 6. 14. 02:03
- 일요일 부터 토요일까지 데이터 가져오기
SELECT * FROM t_order
WHERE YEARWEEK(order_time) = YEARWEEK(now())
-------------------------------------------------------------------
- 월요일 부터 일요일까지 데이터 가져오기
SELECT * FROM t_order
WHERE date(order_time) BETWEEN subdate(curdate(),date_format(curdate(),'%w')-1)
AND subdate(curdate(),date_format(curdate(),'%w')-7);