Interval Data Types
An interval consists of a set of fields. There is an implied ordering among
the fields. For example, in a year-to-month interval, the year comes first,
followed by the month. Similarly, in a day-to-minute interval, the fields are in the
order day, hour, and minute. The first field in an interval type is called the leading field, or the high-order field. The last field is called the trailing field.
In all intervals, the leading field is not constrained by rules of the
Gregorian calendar. For example, in an hour-to-minute interval, the hour field is not
constrained to be between 0 and 23 (inclusive), as it normally is. The trailing
fields subsequent to the leading field follow the usual constraints of the
Gregorian calendar. For more information, see
There are 13 interval SQL data types and 13 interval C data types. Each of the
interval C data types uses the same structure, SQL_INTERVAL_STRUCT, to contain
the interval data. (For more information, see the next section,
Type identifier
| Class
| Description
|
MONTH | Year-Month
| Number of months between two dates.
|
YEAR | Year-Month
| Number of years between two dates.
|
YEAR_ TO_MONTH | Year-Month
| Number of years and months between two dates.
|
DAY | Day-Time
| Number of days between two dates.
|
HOUR | Day-Time
| Number of hours between two date/times.
|
MINUTE | Day-Time
| Number of minutes between two date/times.
|
SECOND | Day-Time
| Number of seconds between two date/times.
|
DAY_TO_HOUR | Day-Time
| Number of days/hours between two date/times.
|
DAY_TO_MINUTE | Day-Time
| Number of days/hours/minutes between two date/times.
|
DAY_TO_SECOND | Day-Time
| Number of days/hours/minutes/seconds between two date/times.
|
HOUR_TO_MINUTE | Day-Time
| Number of hours/minutes between two date/times.
|
HOUR_TO_SECOND | Day-Time
| Number of hours/minutes/seconds between two date/times.
|
MINUTE_TO_SECOND | Day-Time
| Number of minutes/seconds between two date/times.
|