Macros for datetime and interval data types

In addition to the datetime and interval data structures, the datetime.h file defines the macro functions shown in the following table for working directly with qualifiers in binary form.
Table 1. Qualifier macros for datetime and interval data types
Name of Macro Description
TU_YEAR Time unit for the YEAR qualifier field
TU_MONTH Time unit for the MONTH qualifier field
TU_DAY Time unit for the DAY qualifier field
TU_HOUR Time unit for the HOUR qualifier field
TU_MINUTE Time unit for the MINUTE qualifier field
TU_SECOND Time unit for the SECOND qualifier field
TU_FRAC Time unit for the leading qualifier field of FRACTION
TU_Fn Names for datetime ending fields of FRACTION(n), for n from 1 - 5
TU_START(q) Returns the leading field number from qualifier q
TU_END(q) Returns the trailing field number from qualifier q
TU_LEN(q) Returns the length in digits of the qualifier q
TU_FLEN(f) Returns the length in digits of the first field, f, of an interval qualifier
TU_ENCODE(p,f,t) Creates a qualifier from the first field number f with precision p and trailing field number t
TU_DTENCODE(f,t) Creates a datetime qualifier from the first field number f and trailing field number t
TU_IENCODE(p,f,t) Creates an interval qualifier from the first field number f with precision p and trailing field number t
For example, if your program does not provide an interval qualifier in the host-variable declaration, you need to use the interval qualifier macros to initialize and set the interval host variable. In the following example, the interval variable gets a day to second qualifier. The precision of the largest field in the qualifier, day, is set to 2:
/* declare a host variable without a qualifier */
EXEC SQL BEGIN DECLARE SECTION;
   interval inv1;
EXEC SQL END DECLARE SECTION;
;

/* set the interval qualifier for the host variable */
inv1.in_qual = TU_IENCODE(2, TU_DAY, TU_SECOND);
;

/* assign values to the host variable */
incvasc ("5 2:10:02", &inv1);