>
>
> I have a question regarding converting interval values into day, hour,
> minute, second variables, I hope someone can help:
>
> For example, the interval value is defined as :
>
> DEFINE
> usage INTERVAL DAY TO SECOND
>
> and in my 4gl program, I have a value "1 02:30:45" for usage variable.
> now, I want to break down this interval so that I can have one of
> the following variables:
>
> day = 1 (integer)
> hour = 2 (integer)
> minure = 30 (integer)
> second = 45 (integer)
>
> and I want to uses these variable (day, hour...) to do some
> futher calculations
>
MAIN
DEFINE usage INTERVAL DAY TO SECOND,
d1 INTERVAL DAY TO DAY,
i1 INTEGER,
c1 CHAR(4)
LET usage = "1 23:45:54"
DISPLAY usage
LET d1 = usage # loses the HOUR to SECOND portion
LET c1 = d1 # convert to CHAR
LET i1 = c1 # Convert to INT
DISPLAY i1
# Wouldn't it be nice to be able to:
# LET i1 = EXTEND(usage, DAY TO DAY) ?
# .....
# FORMS statement error number -1260.
# It is not possible to convert between the specified types.
END MAIN
There is also a section in the FAQ dealing with my voyage of discovery
through the world of INTERVAL and DATETIME. That might also help you out.
cheers
j.
_____________________________________________________________________________
Jack Parker - Hewlett Packard, DMD/IS Boise, Idaho, USA
jparker@hpbs3645.boi.hp.com
_____________________________________________________________________________
If anything can go wrong, fix it. To hell with Murphy.
_____________________________________________________________________________
Any opinions expressed herein are my own and not those of my employers.
_____________________________________________________________________________