ESQL/C functions for date conversion

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

Table 1. Informix ESQL/C functions for date conversion
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.

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

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

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, US English, uses the format mm/dd/yyyy. For a discussion of GL_DATE and DBDATE, see the Informix GLS User's Guide.