The problem is with "%STARTTIME:~0,2%-100"
being " 1"
, there is an extra space. The program then tries to find the value of (1 1)
instead of (101)
.
The extra 1 in front should only be for systems that output the time as "01:29:25.17"
(to give 101 instead of 01 which the system will interpret as octal number), but for systems that output the time as " 1:29:25.17"
(Note the space in front of the 1) there is a problem (which will give 1 1
).
An easy way is just to remove the 1 in STARTTIME=(1%STARTTIME:~0,2%-100)*360000
and ENDTIME=(1%ENDTIME:~0,2%-100)*360000
, though that might cause a problem with other systems.
A more watertight solution would be to add two lines after the rem line:
rem convert STARTTIME and ENDTIME to centiseconds
set STARTTIME=%STARTTIME: =0%
set ENDTIME=%ENDTIME: =0%
(EDIT: Andriy M's much shorter method above)
There are also two set
in if %ENDTIME% LSS %STARTTIME% set set /A DURATION=%STARTTIME%-%ENDTIME%
which might cause a problem when trying to measure the time between days.