Reference keywords for date arithmetic. These units, such as DAY, HOUR, and MINUTE, specify the interval type used in functions like DATE_ADD and EXTRACT.
The INTERVAL keyword can be used to add or subtract a time interval of time to a DATETIME, DATE or TIME value.
The syntax is:
For example, the SECOND unit is used below by the DATE_ADD() function:
The following units are valid:
MICROSECOND
The time units containing an underscore are composite; that is, they consist of multiple base time units. For base time units, time_quantity is an integer number. For composite units, the quantity must be expressed as a string with multiple integer numbers separated by any punctuation character.
Example of composite units:
Time units can be used in the following contexts:
after a or a operator;
with the following DATE or TIME functions: , , , , , , ;
in the ON SCHEDULE clause of and ;
This page is licensed: CC BY-SA / Gnu FDL
INTERVAL time_quantity time_unitSELECT '2008-12-31 23:59:59' + INTERVAL 1 SECOND;
+-------------------------------------------+
| '2008-12-31 23:59:59' + INTERVAL 1 SECOND |
+-------------------------------------------+
| 2009-01-01 00:00:00 |
+-------------------------------------------+when defining a partitioning BY SYSTEM_TIME .
Microseconds
SECOND
Seconds
MINUTE
Minutes
HOUR
Hours
DAY
Days
WEEK
Weeks
MONTH
Months
QUARTER
Quarters
YEAR
Years
SECOND_MICROSECOND
Seconds.Microseconds
MINUTE_MICROSECOND
Minutes.Seconds.Microseconds
MINUTE_SECOND
Minutes.Seconds
HOUR_MICROSECOND
Hours.Minutes.Seconds.Microseconds
HOUR_SECOND
Hours.Minutes.Seconds
HOUR_MINUTE
Hours.Minutes
DAY_MICROSECOND
Days Hours.Minutes.Seconds.Microseconds
DAY_SECOND
Days Hours.Minutes.Seconds
DAY_MINUTE
Days Hours.Minutes
DAY_HOUR
Days Hours
YEAR_MONTH
Years-Months
INTERVAL '2:2' YEAR_MONTH
INTERVAL '1:30:30' HOUR_SECOND
INTERVAL '1!30!30' HOUR_SECOND -- same as above