[MySQL] 날짜 데이터 다루기 : Date

정재현·2024년 1월 2일

MySQL

목록 보기
17/18
post-thumbnail

날짜 데이터란?

  • yyyy-mm-dd 형식의 데이터

Date란?

  • yyyy-mm-dd 형식의 Column을 data type으로 변경해주는 방법

사용 방법

	date(Column명) 

예시

ex.
	select date(date) date_type,
	       date_format(date(date), '%Y') "년",		// 4자리
	       date_format(date(date), '%m') "월",		// 2자리
	       date_format(date(date), '%Y%m') "년월",
	       date_format(date(date), '%d') "일",		// 2자리
	       date_format(date(date), '%w') "요일"		// 0(일) ~ 6(토)
	from payments

profile
공부 기록 보관소

0개의 댓글