subtracting two user defined time

jie711

New Member
Good day!
sorry about such a mess about my problem...
im problem is how to get the difference of two different user-defined time...

example: 8:45:20 pm
- 7:40:40 pm
----------------
1:04:40

im using the formula x = string(time,'hh:mm:ss am ')
but i really can't figure out the correct code for it...

please have patient with me.... im really not that good in programming.... by the way, thanks to all who help me.. (Paul de Jong and the rest)....
 
U

Unregistered

Guest
Time variables and display

Hi mate,

Progress stores time as if it were an integer value (e.g. 12345) and not as HH:MM:SS (which is only a display string) - UNLESS you have specified data type 'Character' for the field in the database.

So, the
v_difference_in_time = v_time_one - v_time_two
will give you correct results.

Then you might display the v_difference as
display string(v_difference,"HH:MM:SS").

Cheers,
Bert Baker
 
Yes, the problem is the "am" suffix in format string.

DEFINE VARIABLE t1 AS INTEGER NO-UNDO.
DEFINE VARIABLE t2 AS INTEGER NO-UNDO.

t1 = TIME.
t2 = TIME + 100.

DISPLAY STRING(t1,'hh:mm:ss am')
STRING(t2,'hh:mm:ss am')
STRING(t2 - t1,'hh:mm:ss am')
STRING(t2 - t1,'hh:mm:ss').

Regards,
Istvan
 
U

Unregistered

Guest
def var vStartTime as char no-undo.
def var vEndTime as char no-undo.
def var vDiffTime as char no-undo.

def var vSTime as int no-undo.
def var vETime as int no-undo.
def var vDTime as int no-undo.

assign
vStartTime = "8:45:20 pm"
vEndTime = "7:40:40 pm"
vSTime = int(entry(1, vStartTime, ":")) * 3600
+ int(entry(2, vStartTime, ":")) * 60
+ int(substring(entry(3, vStartTime, ":"), 1, 2))
+ (if entry(2, vStartTime, " ") = "pm" then 12 * 3600
else 0)
vETime = int(entry(1, vEndTime, ":")) * 3600
+ int(entry(2, vEndTime, ":")) * 60
+ int(substring(entry(3, vEndTime, ":"),1, 2))
+ (if entry(2, vEndTime, " ") = "pm" then 12 * 3600
else 0)
vDTime = abs(vETime - vSTime)
vDiffTime = string(vDTime, "hh:mm:ss pm").
disp vDiffTime.
 

jie711

New Member
THANKS to all of u!

thanks to all who reply about my problem....

its been very helpful to me....

thanks again....
 
Top