I am trying to use the ESQL function, dttoftmasc provided with Informix ESQL. I am running the following version of ESQL: INFORMIX-ESQL Version 5.01.UD1.
The problem is that when I try to use a format string, I get an error -1228 (which is undefined). If I use a blank format string, the function returns 0 and returns the default format. Also, setting the environment variable DBTIME to anything has no effect on the format.
Am I misusing this function or is this an Informix bug that I don't know about. If it is a known bug, how do I get around it?
Below is the code and the output from running the code.
Thanks in advance,
TJ
-- 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
*---------------------------------------+--------------------------------------*
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;
}
--------------------------What follows is the output ------------------------
Result = -1228 Obuff =
Result = 0 Obuff2 = 1995-03-06 14:14
03/06/95 14:14:46