The ifx_dtcvasc() function

The ifx_dtcvasc() function converts a string that conforms to ANSI SQL standard for a DATETIME value to a datetime value.

Syntax

mint dtcvasc(str, d, dbcentury)
   char *str;
   dtime_t *d;
   char dbcentury;
str
A pointer to the buffer that contains an ANSI-standard DATETIME string.
d
A pointer to an initialized datetime variable.
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 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

You must initialize the datetime variable in d with the qualifier that you want this variable to have.

The character string in str must have values that conform to the year to second qualifier in the ANSI SQL format. The str string can have leading and trailing spaces. However, from the first significant digit to the last, str can only contain characters that are digits and delimiters that conform to the ANSI SQL standard for DATETIME values.

If you specify a year value as one or two digits, the ifx_dtcvasc() function uses the value of the dbcentury argument to determine which century to use. If you do not set the dbcentury argument, ifx_dtcvasc() uses the DBCENTURY environment variable to determine which century to use. If you do not set DBCENTURY, ifx_dtcvasc() assumes the current century for two-digit years. For information about the DBCENTURY environment variable, see the Informix® Guide to SQL: Reference.

If the character string is an empty string, the ifx_dtcvasc() function sets to null the value to which d points. If the character string is acceptable, the function sets the value in the datetime variable and returns zero. Otherwise, the function leaves the variable unchanged and returns a negative error code.

Return codes

0
Conversion was successful.
-1260
It is not possible to convert between the specified types.
-1261
Too many digits in the first field of datetime or interval.
-1262
Non-numeric character in datetime or interval.
-1263
A field in a datetime or interval value is out of range or incorrect.
-1264
Extra characters exist at the end of a datetime or interval.
-1265
Overflow occurred on a datetime or interval operation.
-1266
A datetime or interval value is incompatible with the operation.
-1267
The result of a datetime computation is out of range.
-1268
A parameter contains an invalid datetime qualifier.