Re: ESQL\\C and datetime manipulations
Posted in 1995
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Following is code we use to compare to compare 2 datetime intervals with Infromix 4.1. #include <datetime.h> #include <inf_dtime.h> int cm_dtime_cmp (first, second) CA_DATETIME *first, *second; { int rc; /* If date component of the first parameter is greater than date component of the second parameter */ if (first->date > second->date) return I_MORE; /* If date component of the first parameter is less than date component of the second parameter */ if (first->date < second->date) return I_LESS; /* Compare 2 time components: */ rc = deccmp(&(first->time).dt_dec, &(second->time).dt_dec); if ( rc<0 ) return I_LESS; if ( rc==0 ) return I_OK; if ( rc>0 ) return I_MORE; } where CA_DATETIME is defined as /* CA_DATETIME - type for Informix date and time fields */ TYPEDEF struct { DATE date; dtime_t time; } CA_DATETIME; -- **************************************************************************** * * * * Alan Irom * Motorola Israel Ltd. * * phone: 972-3-565-8862 * Cellular Software Engineering * * fax: 972-3-565-8205 * 3 Kremenetski St. * * e-mail: irom@cig.mot.com * Tel-Aviv 67899 Israel * * * * ****************************************************************************