Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind MySQL DATE_SUB() Function?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___ DATE_SUB("2017-06-15", INTERVAL 10 DAY);3Order
Put the learning moves in the order that makes the concept easiest to apply.
The DATE_SUB() function subtracts a time/date interval from a date and then returns the date.
Definition and Usage
MySQL DATE_SUB() Function
Example
SELECT DATE_SUB("2017-06-15", INTERVAL 10 DAY);Definition and Usage
The DATE_SUB() function subtracts a time/date interval from a date and then returns the date.
Syntax
DATE_SUB(
date
, INTERVAL
value interval
)Parameter Values
| Parameter | Description |
|---|---|
| date | Required. The date to be modified |
| value | Required. The value of the time/date interval to subtract. Both positive and negative values are allowed |
| interval | Required. The type of interval to subtract. Can be one of the following values: 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 |
- 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
Technical Details
| Works in: | From MySQL 4.0 |
|---|