The rfmtdate() function

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

Syntax

mint rfmtdate(jdate, fmtstring, outbuf)
   int4 jdate;
   char *fmtstring;
   char *outbuf;
jdate
The internal representation of a date to convert.
fmtstring
A pointer to the buffer that contains the formatting mask to use the jdate value.
outbuf
A pointer to the buffer that receives the formatted string for the jdate value.

Usage

The fmtstring argument of the rfmtdate() function points to the date-formatting mask, which contains formats that describe how to format the date string. For more information about these date formats, see ids_esqlc_0175.html#ids_esqlc_0175.

The examples in the following list use the formatting mask in fmtstring to convert the integer jdate, whose value corresponds to December 25, 2007, to a formatted string outbuf. You must specify one or more fields.
Formatting mask
Formatted result
"mmdd"
1225
"mmddyy"
122507
"ddmmyy"
251207
"yydd"
0725
"yymmdd"
071225
"dd"
25
"yy/mm/dd"
07/12/25
"yy mm dd"
07 12 25
"yy-mm-dd"
07-12-25
"mmm. dd, yyyy"
Dec. 25, 2007
"mmm dd yyyy"
Dec 25 2007
"yyyy dd mm"
2007 25 12
"mmm dd yyyy"
Dec 25 2007
"ddd, mmm. dd, yyyy"
Tue, Dec. 25, 2007
"ww mmm. dd, yyyy"
Tue Dec. 25, 2007
"(ddd) mmm. dd, yyyy"
(Tue) Dec. 25, 2007
"mmyyddmm"
25071225
""
unpredictable result

Return codes

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.

Example

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

   The following program converts a date from internal format to
   a specified format using rfmtdate().
*/

#include <stdio.h>

main()
{
   char the_date[15];
   int4 i_date;
   mint x;
   int errnum;
   static short mdy_array[3] = { 12, 10, 2007 };

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

   if ((errnum = rmdyjul(mdy_array, &i_date)) == 0)
      {

      /*
       * Convert date to "mm-dd-yyyy" format
       */
      if (x = rfmtdate(i_date, "mm-dd-yyyy", the_date))
         printf("First rfmtdate() call failed with error %d\n", x);
      else
         printf("\tConverted date (mm-dd-yyy): %s\n", the_date);

      /*
       * Convert date to "mm.dd.yy" format
       */
      if (x = rfmtdate(i_date, "mm.dd.yy", the_date))
         printf("Second rfmtdate() call failed with error %d\n",x);
      else
         printf("\tConverted date (mm.dd.yy): %s\n", the_date);

      /*
       * Convert date to "mmm ddth, yyyy" format
       */
      if (x = rfmtdate(i_date, "mmm ddth, yyyy", the_date))
         printf("Third rfmtdate() call failed with error %d\n", x);
       else
         printf("\tConverted date (mmm ddth, yyyy): %s\n", the_date);
      }

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

Output

RFMTDATE Sample ESQL Program running.

   Converted date (mm-dd-yyy): 12-10-2007.
   Converted date (mm.dd.yy): 12.10.07.
   Converted date (mmm ddth, yyyy): Dec 10th, 2007

RFMTDATE Sample Program over.