How to Get Yesterday's Date in MySQL
Robert Cooper
Robert CooperSenior Software Engineer
· January 31, 2025

Robert Cooper
Robert CooperSenior Software Engineer
· January 31, 2025

Retrieving yesterday’s date in MySQL requires you to use the CURDATE() or NOW() functions combined with the INTERVAL keyword. This guide shows how to calculate yesterday’s date and return it in different formats.
MySQL provides several functions for date and time operations. The two commonly used for getting the current date are CURDATE() and NOW(). CURDATE() returns the current date without time, while NOW() returns both date and time.
SELECT CURDATE() as CurrentDate, NOW() as CurrentDateTime;
To get yesterday’s date, subtract one day from the current date. Use the INTERVAL keyword with CURDATE() or NOW().
SELECT CURDATE() - INTERVAL 1 DAY as YesterdayDate;
MySQL’s DATE_FORMAT() function formats the date output. For instance, to get yesterday’s date in a specific format, combine DATE_FORMAT() with the date calculation.
SELECT DATE_FORMAT(CURDATE() - INTERVAL 1 DAY, '%Y-%m-%d') as FormattedYesterdayDate;
Retrieving records based on yesterday’s date is a common use case. For example, to find all entries from a logs table that occurred yesterday:
SELECT *
FROM logs
WHERE DATE(log_date) = CURDATE() - INTERVAL 1 DAY;
When working with time zones, use CONVERT_TZ() together with the date functions so the calculation uses the time zone you want.
SELECT CONVERT_TZ(CURDATE(), '+00:00', 'America/New_York') - INTERVAL 1 DAY as YesterdayDateInNY;
Manipulating dates in MySQL is straightforward with functions like CURDATE() and DATE_FORMAT(). Account for time zones in your calculations to get accurate results.
Written by

Senior Software Engineer
Robert Cooper is a senior engineer who builds full-stack product systems across SQL data infrastructure, APIs, and frontend architecture. His work focuses on application performance, developer velocity, and reliable self-hosted workflows that make data operations easier for teams at scale.
Basedash lets you build charts, dashboards, and reports in seconds using all your data.