DATE_FORMAT() turns DATE, DATETIME, or TIMESTAMP values into strings in any layout you need.
DATE_FORMAT() converts a date or timestamp into a string based on a format mask. Use it when you need readable dates in reports, exports, or UIs.
Provide the date column first, then a format string containing % tokens.MySQL replaces each token with the matching date part.
%Y = four-digit year, %y = two-digit year, %m = zero-padded month, %c = numeric month, %M = full month name, %d = zero-padded day, %H = 24-hour, %i = minute, %s = second.
SELECT id, DATE_FORMAT(order_date,'%M %d, %Y') AS invoice_date FROM Orders;
SELECT DISTINCT DATE_FORMAT(order_date,'%M') AS order_month FROM Orders ORDER BY 1;
SELECT DATE_FORMAT(NOW(),'%Y-%m-%dT%H:%i:%sZ') AS iso_time;
Always store raw DATE/DATETIME values; format them only in SELECTs.Document your masks in code reviews and keep formatting logic in one place.
Using mm instead of %m yields NULL—always prefix tokens with %. Avoid persisting formatted strings; use triggers or app code for presentation.
MySQL 8.0+ supports LOCALE in DATE_FORMAT(): DATE_FORMAT(order_date, '%d %b %Y' LOCALE 'fr_FR') prints French month names.
.
DATE_FORMAT() returns NULL when the input value is NULL. Use COALESCE() to provide a fallback label.
It runs per row, so large reports can slow down. Cache results or format in application code for huge datasets.
DATE_FORMAT() shows the value as stored. Wrap the column with CONVERT_TZ() first when you need timezone adjustments.