[Mysql]날짜 포맷(Date Format)

날짜, 시간에 사용되는 포멧

Format설명
%a요일 단축 영문명

> select date_format(now(), ‘%a’);
Fri
%b월 단축 영문명

> select date_format(now(), ‘%b’);
Feb
%c월 (0 ~ 12)

> select date_format(now(), ‘%c’);
2
%DDay of the month as a numeric value, followed by suffix (1st, 2nd, 3rd, …)

> select date_format(‘2023-01-01’, ‘%D’);
1st
%dDay of the month as a numeric value (01 to 31)

> select date_format(‘2023-01-01’, ‘%d’);
01
%eDay of the month as a numeric value (0 to 31)

> select date_format(‘2023-01-01’, ‘%e’);
1
%fMicroseconds (000000 to 999999)

> select date_format(‘2023-01-01 13:30:12.123456’, ‘%f’);
123456
%HHour (00 to 23)

> select date_format(‘2023-01-01 13:30:12.123456’, ‘%H’);
13
%hHour (00 to 12)

> select date_format(‘2023-01-01 13:30:12.123456’, ‘%h’);
01
%IHour (00 to 12)

> select date_format(‘2023-01-01 13:30:12.123456’, ‘%I’);
01
%iMinutes (00 to 59)

> select date_format(‘2023-01-01 13:30:12.123456’, ‘%i’);
30
%jDay of the year (001 to 366)

> select date_format(‘2023-01-01 13:30:12.123456’, ‘%j’);
001
%kHour (0 to 23)
%lHour (1 to 12)
%MMonth name in full (January to December)
%mMonth name as a numeric value (00 to 12)
%pAM or PM
%rTime in 12 hour AM or PM format (hh:mm:ss AM/PM)
%SSeconds (00 to 59)
%sSeconds (00 to 59)
%TTime in 24 hour format (hh:mm:ss)
%UWeek where Sunday is the first day of the week (00 to 53)
%uWeek where Monday is the first day of the week (00 to 53)
%VWeek where Sunday is the first day of the week (01 to 53). Used with %X
%vWeek where Monday is the first day of the week (01 to 53). Used with %x
%WWeekday name in full (Sunday to Saturday)
%wDay of the week where Sunday=0 and Saturday=6
%XYear for the week where Sunday is the first day of the week. Used with %V
%xYear for the week where Monday is the first day of the week. Used with %v
%YYear as a numeric, 4-digit value
%yYear as a numeric, 2-digit value

You may also like...

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다