I am trying to compare two timestamps (timeA
against timeB
) in the format of HH:MM without seconds, so that I can see if timeB
has a time which is later than 30 minutes or more than the time of timeA
. I can assume that timeB
will always be equal or (most commonly) later than timeA
.
REM 12:42
set "hourA=12"
set "minA=42"
REM 12:49
set "hourB=12"
set "minB=49"
if %hourA% equ %hourB% (
if %minA% equ %minB% (
echo A is equal to B!
) else (
echo A is NOT equal to B!
)
)
I find really hard to implement the logic of checking if timeB
is greater or equal than 30 minutes compared to timeB
for cases like timeA
being 12:42
and timeB
being 13:15
where you need to check for the hours first, then the minutes and then do another check for the hours.
Any suggestions or example code would be great (I am relatively new to batch scripts). The batch script is run on Windows.