+ INTERVAL

From SQLZOO
Revision as of 16:00, 12 July 2012 by Connor (Talk | contribs) (Created page with "<h3>+ INTERVAL</h3> <table align='right' border='1'> <caption>Compatibility</caption> <caption>ABS(f)</caption> <tr><th>Engine</th><th>OK</th><th>Alternative</th></tr> <tr><td...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

+ INTERVAL

Compatibility ABS(f)
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' 

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

SELECT whn, whn+INTERVAL 7 DAY
  FROM eclipse
SELECT whn, whn+INTERVAL 7 DAY
  FROM eclipse