The dttoasc() function

The dttoasc() function converts the field values of a datetime variable to an ASCII string that conforms to ANSI SQL standards.

Syntax

mint dttoasc(dtvalue, outbuf)
   dtime_t *dtvalue;
   char *outbuf;
dtvalue
A pointer to an initialized datetime variable.
outbuf
A pointer to a buffer to receive the ANSI-standard DATETIME string for the value in dtvalue.

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:
YYYY-MM-DD HH:MM:SS.FFFFF

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 values

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