How to Get Yesterday's Date in MySQL?

engrmahabub
Mahabubur Rahman
Published on May, 27 2024 1 min read 0 comments
image

Problem : 

We would like to get yesterday's date in MySQL database. So we need to execute query to solve this. 

 

Solution :

Write bellow query to get yesterday date - 

SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) AS yesterday_date;

Output :

Discussions : 

To get yesterday day you need to substract one day from todays day. You need to use CURDATE() to get todays date. After then you need to substract one day from today using DATE_SUB() function. Here you need to substract one day as DATE_SUB(CURDATE(), INTERVAL 1 DAY)

0 Comments