The datetime.h header file

The datetime.h header file contains definitions for use with the DATETIME and INTERVAL data types.

The header file datetime.h contains the declarations for the date, time, and interval data types, as follows:
  • The internal format represents DATETIME and mi_datetime values with the dtime_t structure.
  • The internal format represents INTERVAL and mi_interval values with the intrvl_t structure.
In addition to these data structures, the datetime.h file defines the constants and macros for date and time qualifiers that the following table shows.
Table 1. Qualifier macros and constants for mi_datetime and mi_interval data types
Name of macro Description
TU_YEAR The time unit for the YEAR qualifier field
TU_MONTH The time unit for the MONTH qualifier field
TU_DAY The time unit for the DAY qualifier field
TU_HOUR The time unit for the HOUR qualifier field
TU_MINUTE The time unit for the MINUTE qualifier field
TU_SECOND The time unit for the SECOND qualifier field
TU_FRAC The time unit for the leading qualifier field of FRACTION
TU_Fn The names for mi_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 an mi_datetime qualifier from the first field number f and trailing field number t
TU_IENCODE(p,f,t) Creates an mi_interval qualifier from the first field number f with precision p and trailing field number t
Tip: For a complete list of date and time macros, consult the datetime.h header file that is installed with your database server. This header file is in the incl/public subdirectory of the INFORMIXDIR directory.
Qualifier macros and constants for mi_datetime and mi_interval data types shows the macro definitions that you can use to compose qualifier values. You need these macros only when you work directly with qualifiers in binary form. For example, if your program does not provide an mi_interval qualifier in the variable declaration, you need to use the mi_interval qualifier macros to initialize and set the mi_interval variable, as the following example shows:
/* Use the variable that was declared intvl1. */
   mi_interval intvl1;
...
/* Set the interval qualifier for the variable */
intvl1.in_qual = TU_IENCODE(2, TU_DAY, TU_SECOND);
...
/* Assign a value to the variable */
incvasc ("5 2:10:02", &intvl1);

In the previous example, the mi_interval variable gets a day to second qualifier. The precision of the largest field in the qualifier, day, is set to 2.

In addition to the declaration of the dtime_t typedef and the preceding date and time macros, the datetime.h header file declares the DATETIME-type functions of the Informix® ESQL/C library. The mitypes.h header file automatically includes datetime.h. In turn, the milib.h header file automatically includes mitypes.h and mi.h automatically includes milib.h. Therefore, you automatically have access to the dtime_t and intrvl_t structures, the mi_datetime and mi_interval data types, any of the date or time macros, or any of the Informix ESQL/C DATETIME-type functions when you include mi.h in your DataBlade® API module.