 |
INFORMIX-ESQL/C Programmer's Manual ESQL/C Function Library |
|
rfmtdate()
The rfmtdate() function uses a formatting mask to convert an internal DATE format to a character string.
Syntax
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 on these date formats, see Formatting Numeric Strings.
The examples in the following table use the formatting mask in fmtstring to convert the integer jdate, whose value corresponds to December 25, 1995, to a formatted string outbuf. You must specify one or more fields.
Formatting Mask
|
Formatted Result
|
"mmdd"
|
1225
|
"mmddyy"
|
122595
|
"ddmmyy"
|
251295
|
"yydd"
|
9525
|
"yymmdd"
|
951225
|
"dd"
|
25
|
"yy/mm/dd"
|
95/12/25
|
"yy mm dd"
|
95 12 25
|
"yy-mm-dd"
|
95-12-25
|
"mmm. dd, yyyy"
|
Dec. 25, 1995
|
"mmm dd yyyy"
|
Dec 25 1995
|
"yyyy dd mm"
|
1995 25 12
|
"mmm dd yyyy"
|
Dec 25 1995
|
"ddd, mmm. dd, yyyy"
|
Mon, Dec. 25, 1995
|
"ww mmm. dd, yyyy"
|
Mon Dec. 25, 1995
|
"(ddd) mmm. dd, yyyy"
|
(Mon) Dec. 25, 1995
|
"mmyyddmm"
|
25951225
|
""
|
unpredictable result
|
When you use a nondefault locale whose dates contain eras, you can use extended-format strings in the fmtstring argument of rfmtdate(). For more information, see the Informix Guide to GLS Functionality.
Return Codes
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, 1994 };
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
INFORMIX-ESQL/C Programmer's Manual, Version 9.21
Copyright © 1999, Informix Software, Inc. All rights reserved