![]() |
|
The rdefmtdate() function uses a formatting mask to convert a character string to an internal DATE format.
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.
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.
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.
The demo directory contains this sample program in the rdefmtdate.ec file.