MySQL Tutorial/Data Types/INTERVAL

Материал из SQL эксперт
Перейти к: навигация, поиск

INTERVAL value Type

Adds the value to the date argument. The word INTERVAL is a keyword and must be used in the function. The Type can be one of the types shown in Table B.1.

Type Expected Value SECOND SECONDS MINUTE MINUTES HOUR HOURS DAY DAYS MONTH MONTHS YEAR YEARS MINUTE_SECOND "MINUTES:SECONDS" HOUR_MINUTE "HOURS:MINUTES" DAY_HOUR "DAYS HOURS" YEAR_MONTH "YEARS-MONTHS" HOUR_SECOND "HOURS:MINUTES:SECONDS" DAY_MINUTE "DAYS HOURS:MINUTES" DAY_SECOND "DAYS HOURS:MINUTES:SECONDS"

If you use one of the types in the first column, the value must match the format in the second column. See DATE_SUB().



SELECT DATE_ADD("2000-01-27", INTERVAL 4 DAY)
SELECT DATE_ADD("2000-04-23 23:59:59", INTERVAL "1:1" MINUTE_SECOND)