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

rdefmtdate()

The rdefmtdate() function uses a formatting mask to convert a character string to an internal DATE format.

Syntax

Usage

The fmtstring argument of the rdefmtdate() function points to the date-formatting mask, which contains formats that describe how to interpret the date string. For more information on these date formats, see Formatting Date Strings.

The input string and the fmtstring must be in the same sequential order in terms of month, day, and year. They need not, however, contain the same literals or the same representation for month, day, and year.

You can include the weekday format (ww), in fmtstring, but the database server ignores that format. Nothing from the inbuf corresponds to the weekday format.

The following combinations of fmtstring and input are valid.

Formatting Mask Input
mmddyy Dec. 25th, 1995
mmddyyyy Dec. 25th, 1995
mmm. dd. yyyy dec 25 1995
mmm. dd. yyyy DEC-25-1995
mmm. dd. yyyy 122595
mmm. dd. yyyy 12/25/95
yy/mm/dd 95/12/25
yy/mm/dd 1995, December 25th
yy/mm/dd In the year 1995, the month of December, it is the 25th day
dd-mm-yy This 25th day of December, 1995

If the value stored in inbuf is a four-digit year, the rdefmtdate() function uses that value. If the value stored in inbuf is a two-digit year, the rdefmtdate() function uses the value of the DBCENTURY environment variable to determine which century to use. If you do not set DBCENTURY, ESQL/C uses the 20th century. For information on how to set DBCENTURY, see the Informix Guide to SQL: Reference.

When you use a nondefault locale whose dates contain eras, you can use extended-format strings in the fmtstring argument of rdefmtdate(). For more information, see the Informix Guide to GLS Functionality.

Return Codes

If you use an invalid date-string format, rdefmtdate() returns an error code and sets the internal DATE to the current date. The following are possible return codes.

0 The operation was successful.
-1204 The *input parameter specifies an invalid year.
-1205 The *input parameter specifies an invalid month.
-1206 The *input parameter specifies an invalid day.
-1209 Because *input does not contain delimiters between the year, month, and day, the length of *input must be exactly six or eight bytes.
-1212 *fmtstring does not specify a year, a month, and a day.

Example

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

Output


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