SQL DATE_FORMAT

DATE_FORMAT(date, format)

%aAbbreviated weekday name (Sun to Sat)
%bAbbreviated month name (Jan to Dec)
%cNumeric month name (0 to 12)
%DDay of the month as a numeric value, followed by suffix (1st, 2nd, 3rd, …)
%dDay of the month as a numeric value (01 to 31)
%eDay of the month as a numeric value (0 to 31)
%fMicroseconds (000000 to 999999)
%HHour (00 to 23)
%hHour (00 to 12)
%IHour (00 to 12)
%iMinutes (00 to 59)
%jDay of the year (001 to 366)
%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

Examples

%Y-%m-%d7/4/2013
%e/%c/%Y4/7/2013
%c/%e/%Y7/4/2013
%d/%m/%Y4/7/2013
%m/%d/%Y7/4/2013
%e/%c/%Y %H:%i4/7/2013 11:20
%c/%e/%Y %H:%i7/4/2013 11:20
%d/%m/%Y %H:%i4/7/2013 11:20
%m/%d/%Y %H:%i7/4/2013 11:20
%e/%c/%Y %T4/7/2013 11:20
%c/%e/%Y %T7/4/2013 11:20
%d/%m/%Y %T4/7/2013 11:20
%m/%d/%Y %T7/4/2013 11:20
%a %D %b %YThu 4th Jul 2013
%a %D %b %Y %H:%iThu 4th Jul 2013 11:20
%a %D %b %Y %TThu 4th Jul 2013 11:20:05
%a %b %e %YThu Jul 4 2013
%a %b %e %Y %H:%iThu Jul 4 2013 11:20
%a %b %e %Y %TThu Jul 4 2013 11:20:05
%W %D %M %YThursday 4th July 2013
%W %D %M %Y %H:%iThursday 4th July 2013 11:20
%W %D %M %Y %TThursday 4th July 2013 11:20:05
%l:%i %p %b %e, %Y7/4/2013 11:20
%M %e, %Y4-Jul-13
%a, %d %b %Y %TThu, 04 Jul 2013 11:20:05



Subscribe To Our Newsletter
You will receive our latest post and tutorial.
Thank you for subscribing!

required
required


Leave a Reply

Your email address will not be published.