How to get 3 days past date from current date Using Batch file

后端 未结 2 1301
鱼传尺愫
鱼传尺愫 2020-12-07 05:55

I am Using \"%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%\" to get current date using batch file

Now how can I get the date of 3 days past from today using Batch

2条回答
  •  自闭症患者
    2020-12-07 06:25

    This will give you a robust date 3 days into the future.

    @echo off
    set day=3
    echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
    echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
    for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
    del "%temp%\%~n0.vbs"
    set "YYYY=%result:~0,4%"
    set "MM=%result:~4,2%"
    set "DD=%result:~6,2%"
    set "d=%yyyy%-%mm%-%dd%"
    
    echo %d%"
    pause
    

提交回复
热议问题