bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

MySQL SUBDATE() Function

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind MySQL SUBDATE() 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.

___ SUBDATE("2017-06-15", INTERVAL 10 DAY);
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The SUBDATE() function subtracts a time/date interval from a date and then returns the date.
Definition and Usage
MySQL SUBDATE() Function

Example

SELECT SUBDATE("2017-06-15", INTERVAL 10 DAY);

Definition and Usage

The SUBDATE() function subtracts a time/date interval from a date and then returns the date.

Syntax

SUBDATE(
date
, INTERVAL
value unit
)

OR

SUBDATE(
date
,
days
)

Parameter Values

ParameterDescription
dateRequired. The original date
daysRequired. The number of days to subtract from date
valueRequired. The value of the time/date interval to subtract. Both positive and negative values are allowed
unitRequired. The type of interval. 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

Previous

MySQL STR_TO_DATE() Function

Next

MySQL SUBTIME() Function