Subtract 10 days from a given date and return the resulting date.
SELECT SUBDATE(“2017-06-15”, INTERVAL 10 DAY); |
The SUBDATE() function subtracts a specified time/date interval from a given date and returns the resulting date.
SUBDATE(date, INTERVAL value unit) |
OR:
SUBDATE(date, days) |
Parameter |
Description |
date |
Required: The initial/original date |
days |
Required: The number of days to subtract from the original date |
value |
Required: The value of the time/date interval to subtract. Both positive and negative values are accepted. |
unit |
Required: The type of interval, which can be one of the following values:
|
Works in: |
From MySQL version 4.0 |
Subtract 15 minutes from a given date and return the resulting date.
SELECT SUBDATE(“2017-06-15 09:34:21”, INTERVAL 15 MINUTE); |
Subtract 3 hours from a given date and return the resulting date.
SELECT SUBDATE(“2017-06-15 09:34:21”, INTERVAL 3 HOUR); |
Add 2 months to a given date and return the resulting date.
SELECT SUBDATE(“2017-06-15”, INTERVAL –2 MONTH); |