Home >> FAQs/Tutorials >> MySQL Tutorials
MySQL Tutorial - Decrementing a Date by 1
(Continued from previous topic...)
How To Decrement Dates by 1?
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)
SELECT DATE('1997-01-31') - INTERVAL 1 DAY FROM DUAL;
(Continued on next topic...)
- What Are Date and Time Data Types?
- How To Write Date and Time Literals?
- How To Enter Microseconds in SQL Statements?
- How To Convert Dates to Character Strings?
- How To Convert Character Strings to Dates?
- What Are Date and Time Intervals?
- How To Increment Dates by 1?
- How To Decrement Dates by 1?
- How To Calculate the Difference between Two Dates?
- How To Calculate the Difference between Two Time Values?
- How To Present a Past Time in Hours, Minutes and Seconds?
- How To Extract a Unit Value from a Date and Time?
- What Are Date and Time Functions?
- What Is TIMESTAMP Data Type?
- How Many Ways to Get the Current Time?