The mi_string_to_datetime() function
The mi_string_to_datetime() function converts a text (string) representation of a date, time, or date and time value to its internal (binary) DATETIME representation.
Syntax
mi_datetime *mi_string_to_datetime(dt_string, type_range)
mi_string *dt_string;
mi_string *type_range;
- dt_string
- A pointer to the date, time, or date and time string to convert to its internal DATETIME format.
- type_range
- A pointer to a string that specifies the range of DATETIME qualifiers in the date, time, or date and time string that dt_string references.
Valid in client LIBMI application? | Valid in user-defined routine? |
---|---|
Yes | Yes |
Usage
The mi_string_to_datetime() function converts the date and/or time string that dt_string references to its internal DATETIME value. An internal DATETIME value is the format that the database server uses to store a value in a DATETIME 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 five digits.
mi_datetime *internal_dt;
...
internal_dt = mi_string_to_datetime(
"2007-01-31 10:30",
"datetime year to minute");
"datetime year to second"
mi_datetime *internal_dt;
...
internal_dt = mi_string_to_datetime(
"2007-05-31 08:52:12",
"datetime year to second");
For GLS, the mi_string_to_datetime() function does not accept the date and/or time string in the date and time formats of the current processing locale.
For more information about how to convert date and/or time strings to internal DATETIME format, see the HCL OneDB™ DataBlade API Programmer's Guide.
Return values
- An mi_datetime pointer
- A pointer to the internal DATETIME representation that mi_string_to_datetime() has created.
- NULL
- The function was not successful.