I am trying to use the dttofmtasc() in ESQL without success. I get an error message -1228 (which is undefined on my system). The only time that I can use the dttofmtasc function without getting a -1228 error is if I use a format string of "".
The Esql version is: INFORMIX-ESQL Version 5.01.UD1.
What am I missing here or is this an Informix bug?
Thanks in advance for the help.
-- TJ Mills IV
*---------------------------------------+--------------------------------------*
| mills@SPK.HP.COM | PHYSICAL: T.J. Mills
| AT&T: (509) 921-3661 | Hewlett Packard Co
| HPDESK: Terence Mills/HP1000 | E 24001 Mission
| TELNET: 1-921-3661 | Liberty Lake WA 99019
*---------------------------------------+--------------------------------------*
Here is the code that I am trying:
EXEC SQL include datetime.h;
EXEC SQL include decimal.h;
#include <iostream.h>
#include <Time.h>
#include "/usr/local/mdm/include/Informix.h"
main() {
EXEC SQL BEGIN DECLARE SECTION;
datetime YEAR TO MINUTE dt;
datetime YEAR TO MINUTE dt2;
EXEC SQL END DECLARE SECTION;
char obuff[50], obuff2[50];
Time tj = Time(1988, Time::november,8);
// init obuffs
strcpy(obuff, "");
strcpy(obuff2, "");
// Init dt
dtcurrent(&dt);
dtcurrent(&dt2);
// Store dt into obuff as ASCII
int x = dttofmtasc(&dt, obuff, sizeof(obuff), "%m/%d/%Y %H:%M");
int y = dttoasc(&dt2, obuff2);
// Print obuffs result
cout << "Result = " << x << " Obuff = " << obuff << endl;
cout << "Result = " << y << " Obuff2 = " << obuff2 << endl;
// Store obuff into tj
tj = make_time(obuff);
// Print tj
cout << tj << endl;
}
Here is the output from running the above code:
Result = -1228 Obuff =
Result = 0 Obuff2 = 1995-03-04 20:50
03/04/95 20:50:36