The rdatestr() function

The rdatestr() function converts an internal DATE to a character string.

Syntax

mint rdatestr(jdate, outbuf)
   int4 jdate;
   char *outbuf;
jdate
The internal representation of the date to format.
outbuf
A pointer to the buffer that receives the string for the jdate value.

Usage

For the default locale, US English, the rdatestr() function determines how to interpret the format of the character string with the following precedence:
  1. The format that the DBDATE environment variable specifies (if DBDATE is set). For more information about DBDATE, see the HCL OneDB™ Guide to SQL: Reference.
  2. The format that the GL_DATE environment variable specifies (if GL_DATE is set). For more information about GL_DATE, see the HCL OneDB GLS User's Guide.
  3. The default date form: mm/dd/yyyy.

When you use a nondefault locale and do not set the DBDATE or GL_DATE environment variable, rdatestr() uses the date end-user format that the client locale defines. For more information, see the HCL OneDB GLS User's Guide.

Return codes

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.

Example

The demo directory contains this sample program in the rtoday.ec file.
/*
   * rtoday.ec *

   The following program obtains today's date from the system.
   It then converts it to ASCII for displaying the result.
*/

#include <stdio.h>

main()
{
   mint errnum;
   char today_date[20];
   int4 i_date;

   printf("RTODAY Sample ESQL Program running.\n\n");

    /* Get today's date in the internal format */
   rtoday(&i_date);

    /* Convert date from internal format into a mm/dd/yyyy string */
   if ((errnum = rdatestr(i_date, today_date)) == 0)
      printf("\n\tToday's date is %s.\n", today_date);
   else
      printf("\n\tError %d in converting date to mm/dd/yyyy\n", errnum);

   printf("\nRTODAY Sample Program over.\n\n");
}

Output

RTODAY Sample ESQL Program running.

   Today's date is 10/26/2007.

RTODAY Sample Program over.