Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   Data Manipulation > Using Date and Time Data Types > Date Data >

Conversion of Date Representations

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.

DataBlade API Functions for Date Conversion

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)
Server Only

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.

End of Server Only
Global Language Support

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.

End of Global Language Support

ESQL/C Functions for Date Conversion

The ESQL/C function library provides the following functions to convert a DATE (mi_date) value to and from char strings.

Function Name
Description
rdatestr( )
Converts an internal format to string
rdefmtdate( )
Converts a string to an internal format using a formatting mask
rfmtdate( )
Converts an internal format to a string using a formatting mask
rstrdate( )
Converts a string to an internal format

The rdatestr( ) and rstrdate( ) functions convert mi_date values to and from a date string that is formatted with the DBDATE environment variable.

Global Language Support

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.

End of Global Language Support

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.

Format
Meaning
dd
Day of the month as a two-digit number (01 through 31)
ddd
Day of the week as a three-letter abbreviation (Sun through Sat)
mm
Month as a two-digit number (01 through 12)
mmm
Month as a three-letter abbreviation (Jan through Dec)
yy
Year as a two-digit number in the 1900s (00 through 99)
yyyy
Year as a four-digit number (0001 through 9999)

Any other characters in the formatting mask are reproduced literally in the result.

Global Language Support

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.

End of Global Language Support
Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]