我正在使用this thread的代碼獲取明天的日期。這是因爲如下:設置變量時出現無效的數字錯誤
@echo off
set /a d=%date:~0,2%
set /a m=%date:~3,2%
set /a y=%date:~6,4%
:loop
set /a d+=1
if %d% gtr 31 (
set d=1
set /a m+=1
if %m% gtr 12 (
set m=1
set /a y+=1
)
)
xcopy /d:%m%-%d%-%y% /l . .. >nul 2>&1 || goto loop
echo %d%/%m%/%y%
但是我收到以下錯誤:雖然在後的文本,它說
Invalid number. Numeric constants are either decimal (17), hexadecimal (0x11), or octal (021).
:
When assigning values to variables, we use using SET /A (rather than just SET) to overcome the problem of attempting to perform octal arithmetic on '08' and '09' later on. This is because leading zeros are trimmed off during arithmetic assignment.
日期格式取決於s在當地/地區設置。你的語言環境是什麼? – Endoro
日期格式是dd-MM-yyyy,就像文章假定的一樣。 – user1151923
如果我將8月份(08)的月份更改爲11月份(10月份),則運行良好。 – user1151923