The mi_string_to_interval() function

The mi_string_to_interval() function converts a text (string) representation of an interval value to its binary (internal) INTERVAL representation.

Syntax

mi_interval *mi_string_to_interval(intvl_string, type_range)
   mi_string *intvl_string;
   mi_string *type_range;
intvl_string
A pointer to the interval string to convert to its internal INTERVAL format.
type_range
A pointer to a string that specifies the range of INTERVAL qualifiers in the interval string that intvl_string references.
Valid in client LIBMI application? Valid in user-defined routine?
Yes Yes

Usage

The mi_string_to_interval() function converts the interval string that intvl_string references to its internal INTERVAL value. An internal INTERVAL value is the format that the database server uses to store a value in an INTERVAL column of the database.

The interval string that intvl_string references has the following fixed format:
"YYYY-MM-DD HH:mm:SS.FFFFF"
YYYY
The 4-digit year.
MM
The 2-digit month.
DD
The 2-digit day.
HH
The 2-digit hour.
mm
The 2-digit minute.
SS
The 2-digit second.
FFFFF
The fraction of a second, in which the date, time, or date and time qualifier specifies the number of digits, with a maximum precision of 5 digits.
However, this interval string can contain only a subset of this range. In this case, the type_range argument must specify the range of qualifiers that the interval string contains. This qualifier range begins with the keyword interval and is followed by the range of qualifiers for the interval in the intvl_string. For example, the following call to mi_string_to_interval() converts the interval of 6 days, 5 hours, and 45 minutes to its internal INTERVAL format:
internal_intvl = mi_string_to_interval(
               "06 5:45",
               "interval day to minute");
If the type_range argument is a NULL-valued pointer, the mi_string_to_interval() function assumes a default qualifier range of:
"interval year to second"

For GLS, the mi_string_to_interval() function does not accept the interval string in the date and time formats of the current processing locale.

For more information about how to convert interval strings to internal INTERVAL format, see the Informix® DataBlade® API Programmer's Guide.

Return values

An mi_interval pointer
A pointer to the internal INTERVAL representation that mi_string_to_interval() has created.
NULL
The function was not successful.