Well, since I was in a rush, I did in fact reinvent the wheel. I'm posting it here just in case anyone has need of it. The following function will accept two time strings (attained by using the TIME() fucntion) and return the hours, minutes, and seconds between the two times. It will not return days, however, since I had no use for it. So, if the difference between the two times is greater than 24 hours the result will be incorrect.
******************************************************************** Procedure TimeElapsed &&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ******************************************************************** Parameter pTimeStart,pTimeEnd PRIVATE xBegHour,xBegMin,xBegSec,; xEndHour,xEndMin,xEndSec,; xHour,xMin,xSec,; xElapsed,xError
xError = "BAD TIME DATA"
IF LEN(pTimeStart)<>8 or LEN(pTimeEnd)<>8 or ; SUBSTR(pTimeStart,3,1)<>":" or SUBSTR(pTimeStart,6,1)<>":" Return xError ENDIF
xBegHour = VAL(SUBSTR(pTimeStart,1,2)) xBegMin = VAL(SUBSTR(pTimeStart,4,2)) xBegSec = VAL(SUBSTR(pTimeStart,7,2)) xEndHour = VAL(SUBSTR(pTimeEnd,1,2)) xEndMin = VAL(SUBSTR(pTimeEnd,4,2)) xEndSec = VAL(SUBSTR(pTimeEnd,7,2))
if xBegHour > xEndHour xHour = (24 - xBegHour)+xEndHour else xHour = xEndHour - xBegHour endif
if xBegMin > xEndMin xMin = (60 - xBegMin)+xEndMin xHour= xHour - 1 else xMin = xEndMin - xBegMin endif
if xBegSec > xEndSec xSec = (60 - xBegSec)+xEndSec if xMin = 0 xMin = 59 xHour= xHour - 1 else xMin = xMin - 1 endif else xSec = xEndSec - xBegSec endif
xElapsed = ALLTRIM(STR(xHour))+"h "+ALLTRIM(STR(xMin))+; "m "+ALLTRIM(STR(xSec))+"s"
Return xElapsed
|