Re: datetime handling in 4GL ( CHAR to DATETIME )
Posted in 1998
I assume that the 'time' column you are selecting is in 'hh:mm:ss' format. If
that is the case, do the equivalent of the following in your code:
define
date_variable date,
char_variable char(8),
temp_char_variable char(19),
datetime_variable datetime year to second
select date_column, time_column into date_variable, char_variablelet temp_char_variable = date_variable using "yyyy-mm-dd", " ", char_variable
let datetime_variable = temp_char_var
Sergey Oleshko wrote:
> I don't understand why are you using CHAR(8) to store time data.
> The DATETIME is preferred fot this purpose.
> Check the time column format first - if it follows
> "HH:MM:SS" rule, the conversion is done implicitly:
> define t datetime year to second
> define s char(8)
> let s = "10:30:15"
> let t = s
> There is no explicit way to convert values with other column formats.
>
> Next, you cannot add two date or datetime values. However, you can subtract
> them to get INTERVAL value and add it to another datetime variable.
> define d date
> define t datetime hour to second
> define t0 datetime hour to second
> define i1 interval hour to second
> define i2 interval year to second
> define r datetime year to second
> define s char(8)
> let d = today -- date (year to day)
> let t = current -- time (hour to second)
> let s = "00:00:00" -- midnight (char)
> let t0 = s -- midnight (time)
> let i1 = t - t0 -- time since midnight
> let i2 = i1 -- expand interval
> let r = d + i2 -- result desired
>
> darredge (darredge@bigpond.com) 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 ?
> :
> : it doesnt seem to handle the time column, is there a trick to converting a
> : CHAR to a DATETIME
> :
> : i keep getting error -1262 Non-numeric character in dtetime or interval
> :
> : thanks
> : Darren Edgerton
> :
> :
> :
> :
>
> --
> S.Oleshko
> International Data Systems
> sol@ids.lviv.ua