로운's 기술노트

[문법] DATE_FORMAT() 함수 본문

내배캠_데이터분석가_'24.04~08/SQL

[문법] DATE_FORMAT() 함수

로운's 2024. 4. 24. 11:20

< 사용법 >

SELECT DATE_FORMAT(date, 매개변수);

 

 

< 매개변수 >

사용 빈도가 높은 매개변수는 하이라이트 처리

No. 단위 형식 내용
1 %X Year for the week where Sunday is the first day of the week. Used with %V
2 %x Year for the week where Monday is the first day of the week. Used with %v
3 %Y Year as a numeric, 4-digit value
4 %y Year as a numeric, 2-digit value
5 %b Abbreviated month name (Jan to Dec)
6 %c Numeric month name (0 to 12)
7 %M Month name in full (January to December)
8 %m Month name as a numeric value (00 to 12)
9 %U Week where Sunday is the first day of the week (00 to 53)
10 %u Week where Monday is the first day of the week (00 to 53)
11 %V Week where Sunday is the first day of the week (01 to 53). Used with %X
12 %v Week where Monday is the first day of the week (01 to 53). Used with %x
13 %D Day of the month as a numeric value, followed by suffix (1st, 2nd, 3rd, ...)
14 %d Day of the month as a numeric value (01 to 31)
15 %e Day of the month as a numeric value (0 to 31)
16 %j Day of the year (001 to 366)
17 요일 %a Abbreviated weekday name (Sun to Sat)
18 요일 %W Weekday name in full (Sunday to Saturday)
19 요일 %w Day of the week where Sunday=0 and Saturday=6
20 오전/오후 %p AM or PM
21 오전/오후 %r Time in 12 hour AM or PM format (hh:mm:ss AM/PM)
22 시간 %H Hour (00 to 23)
23 시간 %h Hour (00 to 12)
24 시간 %I Hour (00 to 12)
25 시간 %k Hour (0 to 23)
26 시간 %l Hour (1 to 12)
27 시간 %T Time in 24 hour format (hh:mm:ss)
28 %i Minutes (00 to 59)
29 %S Seconds (00 to 59)
30 %s Seconds (00 to 59)
31 %f Microseconds (000000 to 999999)

 

- 출처 : MySQL DATE_FORMAT() Function (w3schools.com)

Comments