Data conversion for INTERVAL values

The Informix® ESQL/C library provides functions that convert internal INTERVAL (mi_interval) values to and from char text.

Table 1. Informix ESQL/C functions for data conversion for INTERVAL values
Function name Description
incvasc() Converts an ANSI-compliant character string to an interval value
incvfmtasc() Converts a character string to an interval value
intoasc() Converts an interval value to an ANSI-compliant character string
intofmtasc() Converts an interval value to a string
invextend() Copies an interval value under a different qualifier
The intoasc() and incvasc() functions convert mi_interval values to and from the ANSI SQL standards for INTERVAL strings. The ANSI SQL standards specify qualifiers and formats for character representations of DATETIME and INTERVAL values. The standards for an INTERVAL value specify the following two classes of intervals:
  • The YEAR TO MONTH class has the following format: YYYY-MM

    A subset of this format is also valid: for example, just a month interval.

  • The DAY TO FRACTION class has the following format: DD HH:MM:SS.F

    Any subset of contiguous fields is also valid: for example, MINUTE TO FRACTION.

The intofmtasc() and incvfmtasc() functions convert mi_interval values to and from an interval string using a time-formatting mask. This time-formatting mask contains the same formatting directives that the DBTIME environment variable supports.