Decrementing a Date by 1 in MySQL

Q

How To Decrement Dates by 1 in MySQL?

✍: FYIcenter.com

A

If you have a date, and you want to decrement it by 1 day, you can use the DATE_SUB(date, INTERVAL 1 DAY) function. You can also use the date interval subtraction operation as "date - INTERVAL 1 DAY". The tutorial exercise below gives you some good examples:

SELECT DATE_SUB(DATE('1997-03-01'), INTERVAL 1 DAY)
   FROM DUAL;
   1997-02-28

SELECT DATE('1997-01-31') - INTERVAL 1 DAY FROM DUAL;
   1997-02-28

 

Calculating the Difference between Two Dates in MySQL

Incrementing a Date by 1 in MySQL

Introduction to Date and Time Handling in MySQL

⇑⇑ MySQL Database Tutorials

2017-12-26, 2021🔥, 0💬