Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

datetime handling in 4GL ( CHAR to DATETIME )

2,222 views
Skip to first unread message

Jonathan Leffler

unread,
Jul 13, 1998, 3:00:00 AM7/13/98
to darredge
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 (jlef...@informix.com, jlef...@earthlink.net)
Guardian of DBD::Informix -- see http://www.perl.com/CPAN
#include <disclaimer.h>

darredge

unread,
Jul 14, 1998, 3:00:00 AM7/14/98
to
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

Sergey Oleshko

unread,
Jul 14, 1998, 3:00:00 AM7/14/98
to

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 (darr...@bigpond.com) wrote:

: having trouble using datetime in 4GL ( 6.04.UC1 )

:
:
:
:

--
S.Oleshko
International Data Systems
s...@ids.lviv.ua


Ken Vaughn

unread,
Jul 15, 1998, 3:00:00 AM7/15/98
to
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_variable
let temp_char_variable = date_variable using "yyyy-mm-dd", " ", char_variable
let datetime_variable = temp_char_var

miguel....@misena.edu.co

unread,
Jul 8, 2015, 11:15:47 AM7/8/15
to
GLOBALS
DEFINE extime DATETIME YEAR TO SECOND
END GLOBALS
MAIN
LET extime = CURRENT YEAR TO SECOND
DISPLAY extime
END MAIN


--




*Declinación de Responsabilidades:* Los servicios de MISENA son soportados
tecnológicamente por (c) Google y ofrecidos por el Servicio Nacional de
Aprendizaje - SENA de manera gratuita a los aprendices e instructores de
programas de formación titulada, las opiniones que contenga este mensaje
son exclusivas de su autor y no representan la opinión del Servicio
Nacional de Aprendizaje o de sus autoridades. El receptor deberá verificar
posibles virus informáticos que tenga el correo o cualquier anexo, razón
por la cual el SENA no es responsable de los daños causados por cualquier
virus transmitido en este correo electrónico.

Los contenidos, textos, imágenes, archivos enviados en este mensaje son
responsabilidad exclusiva del remitente y no reflejan ni comprometen de
ninguna manera a la institución. No se autoriza el uso de esta herramienta
para el intercambio de correos masivos, cadenas o spam, ni de mensajes
ofensivos, de carácter político, sexual o religioso, con fines de lucro,
con propósitos delictivos o cualquier otro mensaje que se considere
indebido o que vaya en contra de la Ley.
0 new messages