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.
"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.
internal_intvl = mi_string_to_interval(
"06 5:45",
"interval day to minute");
"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 HCL OneDB™ 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.