반응형
mysql 주차의 첫번째 날 구하기
select
DATE_FORMAT(date_add(date_add(concat(substr(date_val, 1, 4), '-01-01'), INTERVAL substr(date_val, 5, 2)*7 DAY), INTERVAL -weekday(date_add(concat(substr(date_val, 1, 4), '-01-01'), INTERVAL substr(date_val, 5, 2)*7 DAY)) -1 DAY),'%Y%m%d') as test
from
(
select
'202001' as date_val
from dual
) a
반응형