DATE_FORMAT()

발자·2022년 9월 20일
0

SQL

목록 보기
7/8
DATETIME
2015-01-29 15:01:00

DATE_FORMAT(DATETIME, FORMAT)
날짜와 시간을 나타내는 데이터 DATETIME을 가지고 원하는 FORMAT으로 표현하는 함수이다.

FORMAT

SpecifierDescriptionResult
%aAbbreviated weekday name (Sun..Sat)DATE_FORMAT(DATETIME, %a)=Thu
%bAbbreviated month name (Jan..Dec)DATE_FORMAT(DATETIME, '%b')=Jan
%cMonth, numeric (0..12)DATE_FORMAT(DATETIME, '%c')=1
%DDay of the month with English suffix (0th, 1st, 2nd, 3rd, …)DATE_FORMAT(DATETIME, '%D')=29th
%dDay of the month, numeric (00..31)DATE_FORMAT(DATETIME, '%d')=29
%eDay of the month, numeric (0..31)DATE_FORMAT(DATETIME, '%e')=29
%fMicroseconds (000000..999999)DATE_FORMAT(DATETIME, '%f')=000000
%HHour (00..23)DATE_FORMAT(DATETIME, '%H')=15
%hHour (01..12)DATE_FORMAT(DATETIME, '%h')=03
%IHour (01..12)DATE_FORMAT(DATETIME, '%I')=03
%iMinutes, numeric (00..59)DATE_FORMAT(DATETIME, '%i')=01
%jDay of year (001..366)DATE_FORMAT(DATETIME, '%j')=029
%kHour (0..23)DATE_FORMAT(DATETIME, '%k')=15
%lHour (1..12)DATE_FORMAT(DATETIME, '%l')=3
%MMonth name (January..December)DATE_FORMAT(DATETIME, '%M')=January
%mMonth, numeric (00..12)DATE_FORMAT(DATETIME, '%m')=01
%pAM or PMDATE_FORMAT(DATETIME, '%p')=PM
%rTime, 12-hour (hh:mm:ss followed by AM or PM)DATE_FORMAT(DATETIME, '%r')=03:01:00 PM
%SSeconds (00..59)DATE_FORMAT(DATETIME, '%S')=00
%sSeconds (00..59)DATE_FORMAT(DATETIME, '%s')=00
%TTime, 24-hour (hh:mm:ss)DATE_FORMAT(DATETIME, '%T')=15:01:00
%UWeek (00..53), where Sunday is the first day of the week; WEEK() mode 0DATE_FORMAT(DATETIME, '%U')=04
%uWeek (00..53), where Monday is the first day of the week; WEEK() mode 1DATE_FORMAT(DATETIME, '%u')=05
%VWeek (01..53), where Sunday is the first day of the week; WEEK() mode 2; used with %XDATE_FORMAT(DATETIME, '%V')=04
%vWeek (01..53), where Monday is the first day of the week; WEEK() mode 3; used with %xDATE_FORMAT(DATETIME, '%v')=05
%WWeekday name (Sunday..Saturday)DATE_FORMAT(DATETIME, '%W')=Thursday
%wDay of the week (0=Sunday..6=Saturday)DATE_FORMAT(DATETIME, '%w')=4
%XYear for the week where Sunday is the first day of the week, numeric, four digits; used with %VDATE_FORMAT(DATETIME, '%X')=2015
%xYear for the week, where Monday is the first day of the week, numeric, four digits; used with %vDATE_FORMAT(DATETIME, '%x')=2015
%YYear, numeric, four digitsDATE_FORMAT(DATETIME, '%Y')=2015
%yYear, numeric (two digits)DATE_FORMAT(DATETIME, '%y')=15
%%A literal % characterDATE_FORMAT(DATETIME, '%%')=%
%xx, for any “x” not listed aboveDATE_FORMAT(DATETIME, '%x')=x

🧩 출처

0개의 댓글