
select date
from payments

select date(date) date_type,
date
from payments

기본구조
date(날짜 데이터 컬럼 명) as ""
select date(date) date_type,
date_format(date(date), '%Y') "년",
date_format(date(date), '%m') "월",
date_format(date(date), '%d') "일",
date_format(date(date), '%w') "요일"
from payments 
기본구조
date_format(date(날짜 데이터 컬럼 명), '%원하는 날짜') AS ""
예시- 1
다중 date 및 문자 및 특수문자,띄어쓰기 입력도 가능하다
date_format(start_date, '%y-%m') AS "" date_format(start_date, '%y년 %m월 %d일') AS ""
date(date) 쿼리에 date_format을 추가한 구조
날짜 데이터가 포멧팅되면 문자 데이터로 돌아간다.
날짜 데이터는 요일 뿐만아니라 표출되어있지 않은 초 단위도 가능하다.
select date_format(date(date), '%Y') y,
date_format(date(date), '%m') m,
count(1) order_count #날짜와 월이 동일한 수치 카운트(주문 수)
from food_orders a inner join payments b on a.order_id=b.order_id
where date_format(date(date), '%m')='03' # '월'이 03인 날짜 데이터만 조회
group by 1, 2 #년도와 월을 카테고리화한다.
order by 1 #년도를 기준으로 오름차순 한다.
