DATE_FORMAT(date,format)

Description: Returns a date (a DATE or DATETIME type), in a format specified by format as shown in Table C.2.

Table C.2. Display Formats for DATE_FORMAT() and TIME_FORMAT() Functions
Parameter Within FormatOutput FormatExample
%aWeekday name, abbreviatedSun, Mon
%bMonth name, abbreviatedJan
%cMonth without leading 01, 2...12
%DDay of month, suffixed1st, 2nd
%dDay of month with leading 001, 02
%eDay of month without leading 01, 2
%h or %IHour with leading 0 (12h)01, 0212
%HHour with leading 0 (24h)00, 0123
%iMinutes00, 0159
%jDay of year with leading 0's001, 002366
%kHour without leading 0 (24h)0, 123
%lHour without leading 0 (12h)1, 212
%MMonth nameJanuary
%mMonth with leading 001
%PAM or PMAM, PM
%r12-hour time10:30:21 PM
%S or %sSeconds00, 01...59
%T24-hour time22:30:21
%UWeek number in the year[*]01, 02...52
%uWeek number in the year[**]01, 02...52
%X and %VYear and week number[*]2001 52
%x and %vYear and week number[**]2001 52
%WWeekday nameSunday, Monday
%wWeekday number[*]0, 16
%yNumeric year, 2-digit02
%YNumeric year, 4-digit2002
%%Literal % symbol%

[*] in which Sunday is the first day of the week (day 0)

[**] in which Monday is the first day of the week

Examples:

  • DATE_FORMAT('2002-01-05','%W %D %M %Y') returns Saturday 5th January 2002.

  • DATE_FORMAT('2002-01-05 16:20:00','%D %M %Y at %r') returns 5th January 2002 at 04:20:00 PM.

See also: TIME_FORMAT()

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.188.238