The ifx_defmtdate() function

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

Syntax

mint ifx_defmtdate(jdate, fmtstring, instring, dbcentury)
   int4 *jdate;
   char *fmtstring;
   char *instring;
   char dbcentury;
jdate
A pointer to an int4 integer value that receives the internal DATE value for the inbuf string.
fmtstring
A pointer to the buffer that contains the formatting mask to use for the inbuf string.
instring
A pointer to the buffer that contains the date string to convert.
dbcentury
Can be one of the following characters, which determines which century to apply to the year portion of the date:
R
Present. The function uses the two high-order digits of the current year to expand the year value.
P
Past. The function uses the present and past centuries to expand the year value. It compares these two dates against the current date and uses the century that is before the current century. If both dates are before the current date, the function uses the century closest to the current date.
F
Future. The function uses the present and next centuries to expand the year value. It compares these centuries against the current date and uses the century that is later than the current date. If both dates are later than the current date, the function uses the date closest to the current date.
C
Closest. The function uses the present, past, and next centuries to expand the year value. It chooses the century that is closest to the current date.

Usage

The fmtstring argument points to the date-formatting mask, which contains formats that describe how to interpret the date string. For more information about these date formats, see Format 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, 2007
mmddyyyy
Dec. 25th, 2007
mmm. dd. yyyy
dec 25 2007
mmm. dd. yyyy
DEC-25-2007
mmm. dd. yyyy
122507
mmm. dd. yyyy
12/25/07
yy/mm/dd
07/12/25
yy/mm/dd
2007, December 25
yy/mm/dd
In the year 2007, the month of December, it is the 25th day
dd-mm-yy
This 25th day of December 2007

If the value stored in inbuf is a four-digit year, the ifx_defmtdate() function uses that value. If the value stored in inbuf is a two-digit year, the ifx_defmtdate() function uses the value of the dbcentury argument to determine which century to use. If you do not set the dbcentury argument, ifx_defmtdate() uses the DBCENTURY environment variable to determine which century to use. If you do not set DBCENTURY, ifx_strdate() assumes the current century for two-digit years. For information about how to set DBCENTURY, see the HCL OneDB™ Guide to SQL: Reference.

Return codes

If you use an invalid date-string format, ifx_defmtdate() 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 6 or 8 bytes.
-1212
*fmtstring does not specify a year, a month, and a day.