How to judge the time interval in batch BAT?
set XTHH=%time:~0,2% set XTMM=%time:~3,2% set JKSJ=%XTHH%%XTMM% if %JKSJ% leq 0830 ( echo 11111111111111 ) else ( if %JKSJ% geq 1730 ( echo 2222222222 ) else ( echo 333333333333333 ) )
Implementation function: When JKSJ (0830<=JKSJ<=1730), output 333333, otherwise output other (1111111 or 2222222222222222222.
When JKSJ is less than or equal to 0830, output 11111111111111, and when JKSJ is greater than or equal to 1730, output 22222222222, otherwise output 333333333
Problem: When the monitoring time is 0510-0726, the display is incorrect. . There is a bug. . . Logically speaking, 111111 is displayed, but now 33333 is displayed. Does it require some special treatment? Please advise all seniors. . .
Here is a solution to the problem of 08 and 09 that will be considered illegal octal numbers
@echo off set XTHH=%time:~0,2% set XTMM=%time:~3,2% set JKSJ=%XTHH%%XTMM% if 1%JKSJ% leq 10830 ( echo 11111111111111 ) else ( if 1%JKSJ% geq 11730 ( echo 2222222222 ) else ( echo 333333333333333 ) ) pause
illustrate
Numbers starting with 0 will be considered by BAT as octal numbers, and adding a 1 in front of them can avoid this problem.