Time passed till now.

Idod

New Member
Hi ,
I have a table that contains an hour filed (decimal type) and another field with date (date type).

I need a function that return me if x hours (48 hours for example) already passed from the data in the "hour" and "date" filed.

Any idea?

10x.
 
Try this:

Code:
FUNCTION HoursLapsed RETURNS DECIMAL (
    pi_dStartDate AS DATE, pi_iStartHours AS DECIMAL,
    pi_dEndDate AS DATE, pi_iEndHours AS DECIMAL):
    
    RETURN (pi_dEndDate - pi_dStartDate - 1) * 24 + 
           pi_iEndHours + 
           24 - pi_iStartHours.
END FUNCTION.

And some code to check it ....

Code:
FUNCTION HoursLapsed RETURNS DECIMAL (
    pi_dStartDate AS DATE, pi_iStartHours AS DECIMAL,
    pi_dEndDate AS DATE, pi_iEndHours AS DECIMAL):
    
    RETURN (pi_dEndDate - pi_dStartDate - 1) * 24 + 
           pi_iEndHours + 
           24 - pi_iStartHours.
END FUNCTION.
DEFINE VARIABLE d1 AS DATE       NO-UNDO.
DEFINE VARIABLE Hours AS DECIMAL    NO-UNDO.
DEFINE VARIABLE iloop AS INTEGER    NO-UNDO.
DEFINE VARIABLE iDate AS INTEGER    NO-UNDO.
 
DO idate = 0 TO 2:
    DO iloop = 24 TO 0 BY -1:
        
        ASSIGN Hours = DEC(ENTRY (1,STRING (TIME,"hh:mm"),":")) + DEC(ENTRY (2,STRING (TIME,"hh:mm"),":")) / 60.
               d1     = TODAY - idate. 
        DISPLAY d1 iloop Hours HoursLapsed (d1,DEC(iloop),TODAY,Hours) WITH FRAME f1 DOWN.
        DOWN WITH FRAME f1.
    END.
END.

corrected for decimal hours.
 
Back
Top