How to Get Yesterday's Date in MySQL?

Mahabubur Rahman
0
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 yestarday date - 
SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) AS yesterday_date;


Output :

yesterday_date
2023-06-21
 
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)
Tags

Post a Comment

0Comments
Post a Comment (0)