+ INTERVAL

From SQLZoo

+ INTERVAL

Compatibility
d+ INTERVAL i DAY
EngineOKAlternative
mysqlYesd+ i
oracleNod+ i
postgresNod+ i
sqlserverNod+ i

d + INTERVAL i DAY returns the date i days after the date d.

You can also add YEAR, MONTH, DAY, HOUR, MINUTE, SECOND

You can also add a negative value.

 DATE '2006-05-20' + INTERVAL 5 DAY   -> DATE '2006-05-25' 
 DATE '2006-05-20' + INTERVAL 5 MONTH -> DATE '2006-10-20' 
 DATE '2006-05-20' + INTERVAL 5 YEAR  -> DATE '2011-05-20' 
schema:gisq

In this example we show the date 7 days after the value specified in whn

SELECT whn, (whn) + 7 
  FROM gisq.eclipse
SELECT whn, (whn) + 7 
  FROM eclipse
SELECT whn, whn + DATE(7 day)
  FROM eclipse
SELECT whn, whn + 7 
  FROM eclipse
SELECT whn, whn+INTERVAL 7 DAY
  FROM eclipse

See also

Language:Project:Language policy English  • Deutsch
DataWars, Data Science Practice Projects - LogoDataWars: Practice Data Science/Analysis with +100 Real Life Projects
  • Your server today is: digitalocean-sqlzoo