The rdefmtdate() function

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

Syntax

mint rdefmtdate(jdate, fmtstring, inbuf)
   int4 *jdate;
   char *fmtstring;
   char *inbuf;
jdate
A pointer to an int4 variable that receives the internal DATE value for the inbuf string.
fmtstring
A pointer to a buffer that contains the formatting mask to use for the inbuf string.
inbuf
A pointer to the buffer that contains the date string to convert.

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.

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, 2006
mmddyyyy Dec. 25th, 2006
mmm. dd. yyyy dec 25 2006
mmm. dd. yyyy DEC-25-2006
mmm. dd. yyyy 122506
mmm. dd. yyyy 12/25/06
yy/mm/dd 06/12/25
yy/mm/dd 2006, December 25th
yy/mm/dd In the year 2006, the month of December, it is the 25th day
dd-mm-yy This 25th day of December, 2006

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, the DataBlade® API uses the current century. For information about how to set DBCENTURY, see the HCL OneDB™ Guide to SQL: Reference.

Return values

If you use an invalid date-string format, rdefmtdate() returns an error code and sets the internal DATE to the current date. Possible return values follow.
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
The fmtstring parameter does not specify a year, a month, and a day.