Supplemental Examples of MySQL Date Functions
This section lists the syntax and examples of MySQL date functions. These functions will be used in the Workshop. Note similarities and differences to ANSI syntax as previously shown in this chapter. MySQL date functions are listed in addition to ANSI SQL functions because date functions tend to differ between SQL implementations.
DATE_FORMAT
DATE_FORMAT(date,format) formats the date value according to the format string. The following specifiers can be used in the format string:
%M | Month name (January..December) |
%W | Weekday name (Sunday..Saturday) |
%D | Day of the month with English suffix (1st, 2nd, 3rd, etc.) |
%Y | Year, numeric, 4 digits |
%y | Year, numeric, 2 digits |
%X | Year for the week where Sunday is the first day ... |
Get Sams Teach Yourself SQL in 21 Days, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.