thanks Al, whatifi know the time format is 24hr? my batch file won't
run so long, i can think it'll finish in the same day.
OK, here's a demo of a batch routine (":HMS2S") that converts HH:MM:SS.CC
values into seconds, and subtracts the before and after values to show the
duration in seconds. it can handle the troublesome "08" and "09" values,
durations close to a full day, and will return a negative durationifthe
start time is greater than the end time. Feel free to adapt to your
purposes.
/Al
@echo off
call:HMS2S _A %time%
ping -n 7 localhost
call:HMS2S _B %time%
set/a _D = _B - _A
echo/start %_A%
echo/stop %_B%
echo/duration %_D%
call:HMS2S _A 08:08:08
call:HMS2S _B 09:09:09
set/a _D = _B - _A
echo/start %_A%
echo/stop %_B%
echo/duration %_D%
call:HMS2S _A 09:09:09
call:HMS2S _B 08:08:08
set/a _D = _B - _A
echo/start %_A%
echo/stop %_B%
echo/duration %_D%
call:HMS2S _A 01:00:00
call:HMS2S _B 23:59:59
set/a _D = _B - _A
echo/start %_A%
echo/stop %_B%
echo/duration %_D%
pause
GOTO:EOF
:HMS2S
echo/time: %2
(set _time=%2)
(set _time=%_time:~0,8%)
for /f "tokens=1,2,3 delims=:" %%A in ("%_time%") do (
set __HH=1%%A
set __MM=1%%B
set __SS=1%%C
)
rem ::: octal fix for 08 and 09
set/a __HH = __HH - 100
set/a __MM = __MM - 100
set/a __SS = __SS - 100
set/a %1 = __SS + 60 * ( __MM + 24 * ( __HH ) )
GOTO:EOF