The interval data type

Use the interval data type to declare host variables for database values of type INTERVAL.

You specify the accuracy of the interval data type with a qualifier. The qualifier in the following declaration is hour to second:
interval hour to second test_run;
As a host variable, an intrvl_t. represents an interval value:
typedef struct intrvl {
   short in_qual;
   dec_t in_dec;
} intrvl_t;
The intrvl structure and intrvl_t typedef have two parts. The following table lists these parts.
Table 1. Fields in the intrvl structure
Field Description
in_qual Qualifier of the interval value
in_dec Digits of the fields of the interval value This field is a decimal value.
To declare a host variable for an INTERVAL column, use the interval data type followed by an optional qualifier, as shown in the following example:
EXEC SQL BEGIN DECLARE SECTION;
   interval day(3) to day accrued_leave, leave_taken;
   interval hour to second race_length;
   interval scheduled;
EXEC SQL END DECLARE SECTION;

If you omit the qualifier from the declaration of the interval host variable, as in the last example, your program must explicitly initialize the qualifier with the macros described in the following section.