Code: Select all
CHORA1= "8:59"
CHORA2 = "14:30"
------------------------------------------------------------------------------*
ElapTime(cHora1, cHora2) => "06:21:00"
Solucion?
Code: Select all
CHORA1= "8:59"
CHORA2 = "14:30"
------------------------------------------------------------------------------*
ElapTime(cHora1, cHora2) => "06:21:00"
Code: Select all
//----------------------------------------------------------------------------------------------------
Function QTiempo(cTime1, cTime2)
local nSec1, nSec2, nSec3, nHora, nMinu
IF EMPTY(cTime1) .OR. EMPTY(cTime2) .OR. VAL(SUBSTR(cTime2,1,2)) * 3600 + VAL(SUBSTR(cTime2,4,2)) * 60 + VAL(SUBSTR(cTime2,7,2)) = 0
Return("")
EndIf
If VAL(SUBSTR(cTime1,1,2)) > VAL(SUBSTR(cTime2,1,2))
cTime2 := STRZERO( VAL(SUBSTR(cTime2,1,2)) + 24,2 ) + SUBSTR(cTime2,3,6)
EndIf
nSec1 := VAL(SUBSTR(cTime1,1,2)) * 3600 + VAL(SUBSTR(cTime1,4,2)) * 60 + VAL(SUBSTR(cTime1,7,2))
nSec2 := VAL(SUBSTR(cTime2,1,2)) * 3600 + VAL(SUBSTR(cTime2,4,2)) * 60 + VAL(SUBSTR(cTime2,7,2))
nSec3 := nSec2 - nSec1
nHora := nSec3 / 3600
nSec3 := nSec3 - INT(nHora) * 3600
nMinu := nSec3 / 60
nSec3 := nSec3 - INT(nMinu) * 60
Return(STRZERO(nHora,2) + ":" + STRZERO(nMinu,2) + ":" + STRZERO(nSec3,2))