informix
INFORMIX-ESQL/C Programmer's Manual
ESQL/C Function Library

dtcvasc()

The dtcvasc() function converts a string that conforms to ANSI SQL standard for a DATETIME value to a datetime value. For information about the ANSI SQL DATETIME standard, see page 6-15.

Syntax

Usage

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

The character string in inbuf must have values that conform to the year to second qualifier in the ANSI SQL format. The inbuf string can have leading and trailing spaces. However, from the first significant digit to the last, inbuf 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 dtcvasc() function assumes that the year is in the present century. You can set the DBCENTURY environment variable to determine which century dtcvasc() uses when you omit a century from the date.

If the character string is an empty string, the dtcvasc() function sets to null the value to which dtvalue 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.

Example

The demo directory contains this sample program in the dtcvasc.ec file.

Output


INFORMIX-ESQL/C Programmer's Manual, Version 9.21
Copyright © 1999, Informix Software, Inc. All rights reserved