by ukoenig » Mon Sep 16, 2019 8:17 pm
Silvio,
// Return the absolute difference between two times in hh:mm:ss format
// in character hours, minutes and seconds (hh:mm:ss).
// TIME_DIFF( "22:40:12", "23:55:17" ) -> 01:15:05
// TIME_DIFF( "23:55:17", "22:40:12" ) -> 01:15:05
( convert to minutes if needed ) !!
- Code: Select all Expand view RUN
function TIME_DIFF(cTIME1,cTIME2)
local nTIME1, nTIME2, nDELSECS, nHRS, nMINS, nSECS, nSECS1, nSECS2
nSECS1 := (val(substr(cTIME1,1,2)) * 3600) +;
(val(substr(cTIME1,4,2)) * 60) + (val(substr(cTIME1,7)))
nSECS2 := (val(substr(cTIME2,1,2)) * 3600) +;
(val(substr(cTIME2,4,2)) * 60) + (val(substr(cTIME2,7)))
nDELSECS := abs(nSECS2 - nSECS1)
nHRS := int(nDELSECS / 3600)
nMINS := int((nDELSECS - nHRS * 3600) / 60)
nSECS := nDELSECS - (nHRS * 3600) - (nMINS * 60)
return right("00" + ltrim(str(nHRS)),2) + ;
":" + ;
right("00" + ltrim(str(nMINS)),2) + ;
":" + ;
right("00" + ltrim(str(nSECS)),2)
regards
Uwe
Last edited by
ukoenig on Mon Sep 16, 2019 8:41 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.