MySQL provides powerful date and time functions that help developers manipulate, extract, compare, and format date values efficiently in databases.
Date functions operate on DATE, DATETIME, or TIMESTAMP values and return formatted or calculated results.
// Fetches today's date
SELECT CURDATE() AS current_date;
// Returns current date and time
SELECT NOW() AS current_datetime;
// Extracts date from datetime
SELECT DATE('2025-07-18 14:23:45') AS extracted_date;
// Adds 7 days to given date
SELECT DATE_ADD('2025-07-18', INTERVAL 7 DAY) AS new_date;
// Subtracts 3 months from date
SELECT DATE_SUB('2025-07-18', INTERVAL 3 MONTH) AS new_date;
// Formats date into readable string
SELECT DATE_FORMAT('2025-07-18', '%W, %M %d, %Y') AS formatted_date;
These queries return calculated or formatted dates directly from the MySQL server, useful for reports and dashboards.
Combine CURDATE() with DATE_ADD() to dynamically calculate deadlines or expiration dates.