Home »
MySQL »
MySQL date/time Functions
MySQL SUBDATE() Function
MySQL | SUBDATE() Function: Learn about the SUBDATE() function, how it works, its usages, syntax, and examples.
Submitted by Apurva Mathur, on October 13, 2022
SUBDATE() Function
The SUBDATE() function subtracts the date from the given interval and as a result, it returns the date after the subtraction of the interval.
SUBDATE() Syntax
SELECT SUBDATE(datetime value, interval);
SUBDATE() Parameter(s)
This function takes two parameters-
- datetime value: You can provide a particular datetime value or you can also provide the number of days you want to subtract.
- interval: There are different types of intervals that we can add to this function, which are as follows,
- MICROSECOND
- SECOND
- MINUTE
- HOUR
- DAY
- WEEK
- MONTH
- QUARTER
- YEAR
- SECOND_MICROSECOND
- MINUTE_MICROSECOND
- MINUTE_SECOND
- HOUR_MICROSECOND
- HOUR_SECOND
- HOUR_MINUTE
- DAY_MICROSECOND
- DAY_SECOND
- DAY_MINUTE
- DAY_HOUR
- YEAR_MONTH
SUBDATE() Return Value
As a result, this function will return you the date after the subtraction of the interval which you have provided.
MySQL SUBDATE() Function Example 1
SELECT SUBDATE("2019-09-12", INTERVAL 1 YEAR);
MySQL SUBDATE() Function Example 2
SELECT SUBDATE("2022-09-22", INTERVAL 2 MONTH);
MySQL SUBDATE() Function Example 3
SELECT SUBDATE("2012-10-12 18:09:36", INTERVAL 6 HOUR);