Reputation: 1872
I am using the code from this thread to get tomorrow's date. It is as follows:
@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%
However I am getting the following error:
Invalid number. Numeric constants are either decimal (17), hexadecimal (0x11), or octal (021).
Although the in the post's text it says:
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.
Upvotes: 0
Views: 3531
Reputation: 37579
assuming, you have leading zeros in day and month:
set /a d=1%date:~0,2%-100 set /a m=1%date:~3,2%-100 set /a y=%date:~6,4%
Upvotes: 7