The ifx_strdate() function

The ifx_strdate() function converts a character string to an internal DATE.

Syntax

mint ifx_strdate(str, jdate, dbcentury)
   char *str;
   int4 *jdate;
   char dbcentury;
str
A is a pointer to the string that contains the date to convert.
jdate
A pointer to a int4 integer that receives the internal DATE value for the str string.
dbcentury
Can be one of the following characters, which determines which century to apply to the year portion of the date:
R
Present. The function uses the two high-order digits of the current year to expand the year value.
P
Past. The function uses the past and present centuries to expand the year value. It compares these two dates against the current date and uses the century that is before the current century. If both dates are before the current date, the function uses the century closest to the current date.
F
Future. The function uses the present and the next centuries to expand the year value. It compares these centuries against the current date and uses the century that is later than the current date. If both dates are later than the current date, the function uses the date closest to the current date.
C
Closest. The function uses the past, present, and next centuries to expand the year value. It chooses the century that is closest to the current date.

Usage

For the default locale, US English, the ifx_strdate() function determines how to format the character string with the following precedence:
  1. The format that the DBDATE environment variable specifies (if DBDATE is set). For more information about DBDATE, see the Informix® Guide to SQL: Reference.
  2. The format that the GL_DATE environment variable specifies (if GL_DATE is set). For more information about GL_DATE, see the Informix® GLS User's Guide.
  3. The default date form: mm/dd/yyyy. You can use any nonnumeric character as a separator between the month, day, and year. You can express the year as four digits (2007) or as two digits (07).

When you use a nondefault locale and do not set the DBDATE or GL_DATE environment variable, ifx_strdate() uses the date end-user format that the client locale defines. For more information, see the Informix® GLS User's Guide.

When you use a two-digit year in the date string, the ifx_strdate() function uses the value of the dbcentury argument to determine which century to use. If you do not set the dbcentury argument, ifx_strdate() uses the DBCENTURY environment variable to determine which century to use. If you do not set DBCENTURY, ifx_strdate() assumes the current century for two-digit years. For information about the DBCENTURY environment variable, see the Informix® Guide to SQL: Reference.

Return codes

0
The conversion was successful.
< 0
The conversion failed.
-1204
The str parameter specifies an invalid year.
-1205
The str parameter specifies an invalid month.
-1206
The str parameter specifies an invalid day.
-1212
Data conversion format must contain a month, day, or year component. DBDATE specifies the data conversion format.
-1218
The date specified by the str argument does not properly represent a date.