The INTERVAL data type

The SQL INTERVAL data type holds the internal (binary) format of an interval value. It encodes a value that represents a span of time. INTERVAL types are divided into two classes: year-month intervals and day-time intervals. A year-month interval can represent a span of years and months, and a day-time interval can represent a span of days, hours, minutes, seconds, and fractions of a second.

Tip: The internal format of the INTERVAL data type is often referred to as its binary representation.
The INTERVAL data type uses a computer-independent method to encode the interval qualifiers. It stores the information in the intrvl_t structure, as follows:
typedef struct intrvl {
   short in_qual;
   dec_t in_dec;
} intrvl_t;
The intrvl structure and intrvl_t typedef have the two parts that the following table shows.
in_qual
The qualifier of the interval value
in_dec
The digits of the fields of the interval value

This field is a decimal value.

The DataBlade® API supports the SQL INTERVAL data type with the mi_interval data type. Therefore, an mi_interval data type holds the binary representation of an interval value.

Values of the mi_interval data type cannot fit into an MI_DATUM structure. They must be passed by reference within C UDRs.

All data types, including mi_interval, must be passed by reference within client LIBMI applications.

Because the binary representation of an INTERVAL (mi_interval) value is a proprietary format of HCL Informix®, you cannot use standard system functions to perform operations on mi_interval values. Instead, the DataBlade API provides the following support for the INTERVAL data type.
  • Conversion functions
  • Arithmetic-operation functions