The datetime data type
Use the datetime data type to declare host variables for database values of type DATETIME. You specify the accuracy of the datetime data type with a qualifier.
For example, the qualifier in the following declaration
is year to day:
datetime year to day sale;
As a host variable, a dtime_t. structure represents
a datetime value:
typedef struct dtime {
short dt_qual;
dec_t dt_dec;
} dtime_t;
The dtime structure and dtime_t typedef
have two parts. The following table lists these parts.
Field | Description |
---|---|
dt_qual | Qualifier of the datetime value |
dt_dec | Digits of the fields of the datetime value This field is a decimal value. |
Declare a host variable for a DATETIME column with the datetime data
type followed by an optional qualifier, as the following example shows:
EXEC SQL include datetime;
EXEC SQL BEGIN DECLARE SECTION;
datetime year to day holidays[10];
datetime hour to second wins, places, shows;
datetime column6;
EXEC SQL END DECLARE SECTION;
If you omit the qualifier from the declaration of the datetime host variable, as in the last example, your program must explicitly initialize the qualifier with the macros shown in Qualifier macros for datetime and interval data types.