Contents


Date Functions


rdatestr()

Purpose:

To convert a date that is in the native database date format to a string

Syntax:

mint rdatestr(int4 jdate, char *str);

Notes:

  1. jdate is the internal representation of the date to format.
  2. str is a pointer to the buffer that receives the string for the date value.

Return code:

0            The conversion was successful.
<0          The conversion failed.
-1210     The internal date could not be converted to the character string format.
-1212     Data conversion format must contain a month, day, or year component.
 

DBDATE specifies the data conversion format.


rdayofweek()

Purpose:

Returns the day of the week of a date that is in the native database format

Syntax:

mint rdayofweek(int4 jdate);

Notes:

  1. jdate is the internal representation of the date.

Return code:

0     Sunday
1     Monday
2     Tuesday
3     Wednesday
4     Thursday
5     Friday
6     Saturday


rdefmtdate()

Purpose:

To convert a string in a specified format to the native database date format

Syntax:

mint rdefmtdate(int4 *pdate, char *fmtstring, char *input);

Notes:

  1. pdate is a pointer to an int4 integer value that receives the internal DATE value for the input string.
  2. fmtstring is a pointer to the buffer that contains the formatting mask for the string.
  3. input is a pointer to the buffer that contains the string to convert.

Return code:

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.


rfmtdate()

Purpose:

To convert a date that is in the native database date format to a string having a specified format

Syntax:

mint rfmtdate(int4 jdate, char *fmtstring, char *result);

Notes:

  1. jdate is the internal representation of a date to convert.
  2. fmtstring is a pointer to the buffer containing the formatting mask.
  3. result is a pointer to the buffer that receives the formatted string.

Return code:

0         The conversion was successful.
-1210 The internal date cannot be converted to month-day-year format.
-1211 The program ran out of memory (memory-allocation error).
-1212 Format string is NULL or invalid.


rjulmdy()

Purpose:

To create an array of short integer values representing year, month, and day from a date that is in the native database date format

Syntax:

mint rjulmdy(int4 jdate, int2 mdy[3]);

Notes:

  1. jdate is the internal representation of a date.
  2. mdy is an array of short integers, where mdy[0] is the month (1 to 12), mdy[1] is the day (1 to 31), and mdy[2] is the year (1 to 9999).

Return code:

0         The operation was successful.
< 0     The operation failed.
-1210 The internal date could not be converted to the character string format.


rleapyear()

Purpose:

To determine whether the value passed as a parameter is a leap year; returns 1 when TRUE.

Syntax:

mint rleapyear(mint year);

Notes:

  1. year is an integer, representing the year component of a date, in the full form yyyy (ie, 2004).

Return code:

1     The year is a leap year.
0     The year is not a leap year.


rmdyjul()

Purpose:

To create a value in the native database date format from an array of short integer values representing month, day, and year

Syntax:

mint rmdyjul(int2 mdy[3], int4 *jdate);

Notes:

  1. mdy is an array of short integer values, where mdy[0] is the month (1 to12), mdy[1] is the day (1 to 31), and mdy[2] is the year (1 to 9999).
  2. jdate is a pointer to a long integer that receives the internal DATE value for the mdy array.

Return code:

0         The operation was successful.
-1204 The mdy[2] variable contains an invalid year.
-1205 The mdy[0] variable contains an invalid month.
-1206 The mdy[1] variable contains an invalid day.


rstrdate()

Purpose:

To convert a character string to the native database date format.

Syntax:

mint rstrdate(char *str, int4 *jdate);

Notes:

  1. str is a pointer to a char string containing the date to convert.
  2. jdate is a pointer to an int4 integer that receives the converted date value.

Return code:

0        The conversion was successful.
< 0     The conversion failed.
-1204 The str parameter specifies an invalid year.
-1205 The str parameter specifies an invalid month.
-1206 The str parameter specifies an invalid day.
-1212 Data conversion format must contain a month, day, or year component. DBDATE specifies the data conversion format.
-1218 The date specified by the str argument does not properly represent a date.


rtoday()

Purpose:

Returns the system date in the internal database date format

Syntax:

void rtoday(int4 *today);

Notes:

  1. today is a pointer to an int4 value that receives the internal date.

ifx_defmtdate()

Purpose:

To convert a string in a specified format to the native database date format; allows you to specify the century setting for two-digit dates.

Syntax:

mint ifx_defmtdate(int4 *pdate, char *fmtstring, char *input,
                   char db_century);

Notes:

  1. pdate is a pointer to an int4 integer value that receives the internal DATE value for the input string.
  2. fmtstring is a pointer to the buffer that contains the formatting mask to use for the input string.
  3. input is a pointer to the buffer that contains the date string to convert.
  4. db_century is one of the following characters, which determines which century to apply to the year portion of the date:
Character  Description
R    Present. The function uses the present century to expand the year value.

 

 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 prior to the current century. If both dates are prior to 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 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.

ifx_strdate()

Purpose:

To convert a character string to the native database date format; allows you to specify the century setting for two-digit dates.

Syntax:

mint ifx_strdate(char *str, int4 *jdate, char db_century);

Notes:

  1. str is a pointer to the string that contains the date to convert.
  2. jdate is a pointer to a int4 integer that receives the internal DATE value for the str string.
  3. db_century is one of the following characters, which determines which century to apply to the year portion of the date:
Character  Description
R    Present. The function uses pressent century to expand the year value.

 

 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 prior to the current century. If both dates are prior to 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 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.

 


Formatting Mask

A date-formatting mask specifies a format to apply to some date value. This mask is a combination of the following formats:
 

Character  Description
dd    Day of the month as a two-digit number (01 through 31)
ddd    Day of the week as a three-letter abbreviation (Sun through Sat)
mm    Month as a two-digit number (01 through 12)
mmm    Month as a three-letter abbreviation (Jan through Dec)
yy    Year as a two-digit number (00 through 99)
yyyy    Year as a four-digit number (0001 through 9999)
ww    Day of the week as a two-digit number (00 for Sunday, 01 for Monday, 02 for Tuesday … 06 for Saturday)


Any other characters in the formatting mask are reproduced literally in the result.