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

dttofmtasc()

The dttofmtasc() function uses a formatting mask to convert a datetime variable to a character string.

Syntax

Usage

You must initialize the datetime variable in dtvalue with the qualifier that you want the character string to have. If you do not initialize the datetime variable, the function returns an unpredictable value. The character string in outbuf does not include the qualifier or the parentheses that SQL statements use to delimit a DATETIME literal.

The formatting mask, fmtstring, does not need to imply the same qualifiers as the datetime variable. When the implied formatting-mask qualifier is different from the datetime qualifier, dttofmtasc() extends the datetime value (as if it called the dtextend() function).

If the formatting mask is an empty string, the function sets character string, outbuf, to an empty string. If fmtstring is a null pointer, the dttofmtasc() function must determine the format to use for the character string in outbuf. When you use the default locale, the function uses the following precedence:

  1. The format that the DBTIME environment variable specifies (if DBTIME is set). For more information on DBTIME, ../sqlr/intro.htmler to the Informix Guide to SQL: Reference.
  2. The format that the GL_DATETIME environment variable specifies (if GL_DATETIME is set). For more information on GL_DATETIME, refer to the Informix Guide to GLS Functionality.
  3. The default date format that conforms to the standard ANSI SQL format:

When you use a two-digit year (%y) in a formatting mask, the dttofmtasc() function uses the value of the DBCENTURY environment variable to determine which century to use. If you do not set DBCENTURY, dttofmtasc() assumes the present century for two-digit years. For information on how to set DBCENTURY, see the Informix Guide to SQL: Reference.

When you use a nondefault locale (one other than U.S. English) and do not set the DBTIME or GL_DATETIME environment variables, dttofmtasc() uses the default DATETIME format that the client locale defines. For more information, see the Informix Guide to GLS Functionality.

Return Codes

0 The conversion was successful.
<0 The conversion failed. Check the text of the error message.

Example

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

Output


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