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

dttoasc()

The dttoasc() function converts the field values of a datetime variable to an ASCII string that conforms to ANSI SQL standards. For information about the ANSI SQL DATETIME standard, see page 6-15.

Syntax

Usage

The dttoasc() function converts the digits of the fields in the datetime variable to their character equivalents and copies them to the outbuf character string with delimiters (hyphen, space, colon, or period) between them. You must initialize the datetime variable in dtvalue with the qualifier that you want the character string to have.

The character string does not include the qualifier or the parentheses that SQL statements use to delimit a DATETIME literal. The outbuf string conforms to ANSI SQL standards. It includes one character for each delimiter, plus the fields, which are of the following sizes.

Field Field Size
Year Four digits
Fraction of DATETIME As specified by precision
All other fields Two digits

A datetime value with the year to fraction(5) qualifier produces the maximum length of output. The string equivalent contains 19 digits, 6 delimiters, and the null terminator, for a total of 26 bytes:

If you do not initialize the qualifier of the datetime variable, the dttoasc() function returns an unpredictable value, but this value does not exceed 26 bytes.

Return Codes

0 The conversion was successful.
<0 The conversion failed.

Example

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

Output


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