darredge wrote:
> having trouble using datetime in 4GL ( 6.04.UC1 )
>
> i am using a cursor to select a date column, and a time column
> (char(8)) into variables and then want to combine these two
> variables into a single datetime.
>
> how?
Why? Or, more specifically, why are they separated, and why aren't
they in DATETIME formats anyway?
Oh well, too late, no doubt.
> it doesnt seem to handle the time column, is there a trick to
> converting a CHAR to a DATETIME
Yes; think of it as an interval and not as a DATETIME.
DEFINE x DATE
DEFINE y CHAR(8)
DEFINE dt1 DATETIME YEAR TO DAY
DEFINE dt2 DATETIME YEAR TO SECOND
DEFINE dt3 DATETIME HOUR TO SECOND
LET x = MDY(2,29,2000)
LET y = "23:59:59"
LET dt1 = DATETIME(x) YEAR TO DAY
LET dt2 = EXTEND(dt1, YEAR TO SECOND) + INTERVAL(y) YEAR TO SECOND
Alternatively, if you must use DATETIME,
LET dt3 = DATETIME(y) HOUR TO SECOND
LET dt2 = EXTEND(dt1, YEAR TO SECOND) +
(dt3 - DATETIME(0) SECOND TO SECOND)
> i keep getting error -1262 Non-numeric character in datetime or
> interval
I haven't actually put the code above past a compiler, but it should
be correct.
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix -- see http://www.perl.com/CPAN
#include <disclaimer.h>