INTERVAL is driving me crazy
Posted in 1999
Topics: General Discussion
I'm trying to convert datetime values from one timezone to another, however it seems that the value of INTERVAL can only be a constant. Any ideas how I can increment/decrement a DATETIME according to an INT variable that represents minutes?
FAIK INTERVAL variables are perfectly valid in 4GL, SPL, and ESQL, and probably CLI to boot. There is no reason you cannot do the following, check the header $INFORMIXDIR/incl/esql/datetime.h or the ESQL manual for the macros: int offset; char offs_str[6]; EXEC SQL BEGIN DECLARE SECTION; intrvl_t Zone_offs; EXEC SQL END DECLARE SECTION; /* Set qualifier to MINUTE(4) TO MINUTE */ Zone_Offs.in_qual = TU_IENCODE( 4, TU_MINUTE, TU_MINUTE ); /* Assign timezone offset of 4 hours to the interval. */ offset = 4; sprintf( offs_str, "%d", (offset * 60)); incvasc( offs_str, &Zone_Offs ); EXEC SQL DECLARE fetcher CURSOR FOR SELECT gm_time + :Zone_Offs FROM mytable; :::::: Art S. Kagel David Henry wrote: > > I'm trying to convert datetime values from one timezone to another, however > it > seems that the value of INTERVAL can only be a constant. > Any ideas how I can increment/decrement a DATETIME according to an INT > variable that represents minutes?