Re: Manipulating DATETIME/INTERVAL in ESQL/C
Posted in 1995
Min Qiu (min@sura.net) wrote: : Does informix 4.0 ESQL/C has funtion to +/- datetime or interval : values like 4gl? And How? I have the following info for 4.0: ************************************************************************ Title: How to manipulate datetime in 4.0 ESQL/C Customers may want to do manipulation of datetime and interval data types in ESQL/C beyond just selecting and printing them. They may want to retrieve two datetimes and then compare them in their programs. A look through the ESQL/C manual will show that there is no mention of how that might be done. Here are 4 functions that are not documented anywhere. They *are* (at least in this release) part of the esql/c library, and as such are available for use. The definition of these functions are: -------------------------------------- rdtsub(dt1, dtq1, dt2, dtq2, dt3, dtq3) dec_t *dt1, *dt2, *dt3; int dtq1, dtq2, dtq3; Subtract a datetime from a datetime, yielding a interval. dt1 and dt2 are the operands and dt3 is the result (i.e., dt3 = dt1 - dt2) -------------------------------------- rdtaddinv(dt1, dtq1, dt2, dtq2, dt3) dec_t *dt1, *dt2, *dt3; int dtq1, dtq2; Add an interval to a datetime, yielding a datetime. dt1 and dt2 are the operands and dt3 is the result (i.e., dt3 = dt1 + dt2) -------------------------------------- rinvtodec(pinv, dtqual, pdec) dec_t *pinv; /* interval value */ int dtqual; /* interval qualifier */ dec_t pdec; /* decimal result */ Convert an interval/datetime value to a decimal pinv is the interval/datetime and pdec is the resulting decimal value. -------------------------------------- rdectoinv(pdec, pinv, dtqual) dec_t pdec; /* decimal value */ dec_t *pinv; /* interval result */ int dtqual; /* interval qualifier */ Convert a decimal value to an interval/datetime pdec is the decimal value, pinv is the datetime/interval result -------------------------------------- All other operations use the decimal functions of ESQL/C. < The FAX goes on with about 6 pages of sample code that I'm not about to type in. I might be persuaded into a small sample if you need it. Or, I can FAX. > ************************************************************************ If you're using 6.0, the rdtsub() and rdtaddinv() functions have been replaced by dtsub() and dtaddinv(), with some parameter changes as well. -Joel Schumacher JCPenney Co. - UNIX Network Systems 12700 Park Central Pl. M/S 6019 Dallas, TX 75251 jschumac@uns-dv1.jcpenney.com OR jschumac@jcpenney.com