SQL - Interval

About

time duration is known as interval in SQL.

Syntax

An SQL interval data type descriptor contains:

  • the name of the interval data type (INTERVAL);
  • an indication of whether the interval data type is :
    • a year-month interval. It can include only YEAR, MONTH field and not both field are required.
    • or a day-time interval. It can include any fields other than YEAR or MONTH.
  • the <interval qualifier> that describes the precision of the interval data type.

Operations

Datetime  -  Datetime  = Interval
Datetime  + or -  Interval  = Datetime
Interval + Datetime = Datetime
Interval + or - Interval = Interval
Interval * or / Numeric = Interval
Numeric * Interval = Interval

Powered by ComboStrap