Datetime interval literals

 

The ODBC escape sequence for a datetime interval literal is:

 

{INTERVAL [ + | - ] ‘valueinterval-qualifier}

 

where value is the value to be converted and interval-qualifier is either a single datetime field or a value composed of two datetime fields, in the form: leading field TO trailing field. For example, the ODBC escape sequence:

 

{INTERVAL '163-11' YEAR(3) TO MONTH}

 

specifies an interval of 163 years and 11 months. The interval leading precision is 3.

 

All interval literals begin with the word "INTERVAL". This keyword, along with the opening brace, is sufficient to indicate that it is an interval literal. If the data source supports a datetime interval data type, its driver must also support the corresponding ODBC escape sequence. Data source drivers can also support the datetime literals defined in the ANSI SQL92 specification, which are different from the ODBC escape sequences for datetime interval literals.