Both the DataBlade API library and the ESQL/C library provide functions that convert from the text (string) representation of a date value to the binary (internal) representation for DATE.
The DataBlade API provides the following functions for conversion between text and binary representations of date data.
DataBlade API Function | Convert from | Convert to |
---|---|---|
mi_date_to_string( ) | DATE (mi_date) | Date string |
mi_string_to_date( ) | Date string | DATE (mi_date) |
The mi_date_to_string( ) and mi_string_to_date( ) functions are useful in the input and output support functions of an opaque data type that contains mi_date values. They allow you to convert DATE values between their external format (text) and their internal (binary) format when transferred to and from client applications. For more information, see Conversion of Opaque-Type Data Between Text and Binary Representations.
The mi_date_to_string( ) and mi_string_to_date( ) functions use the current processing locale to handle locale-specific formats in the date string. For more information, see the IBM Informix: GLS User's Guide.
The ESQL/C function library provides the following functions to convert a DATE (mi_date) value to and from char strings.
The rdatestr( ) and rstrdate( ) functions convert mi_date values to and from a date string that is formatted with the DBDATE environment variable.
These functions also examine the GL_DATE environment variable for the format of the date string. When you use a nondefault locale and do not set the DBDATE or GL_DATE environment variable, rdatestr( ) uses the date end-user format that the client locale defines. For more information, see the IBM Informix: GLS User's Guide.
The rdefmtdate( ) and rfmtdate( ) functions convert mi_datetime values to and from a date-time string using a date-formatting mask. A date-formatting mask specifies a format to apply to some date value. This mask is a combination of the following formats.
Any other characters in the formatting mask are reproduced literally in the result.
When you use a nondefault locale whose dates contain eras, you can use extended-format strings in a numeric-formatting mask. For more information, see the IBM Informix: GLS User's Guide.
When you use rfmtdate( ) or rdefmtdate( ) to format DATE values, the function uses the date end-user formats that the GL_DATE or DBDATE environment variable specifies. If neither of these environment variables is set, these date-formatting functions use the date end-user formats for the locale. The default locale, U.S. English, uses the format mm/dd/yyyy. For a discussion of GL_DATE and DBDATE, see the IBM Informix: GLS User's Guide.