@echo off
rem 指定月数
set MonthsAgo=2
>"%temp%/DateCalculate.vbs" echo strLastDate=
dateadd("m", -%MonthsAgo%, Date)
>>"%temp%/DateCalculate.vbs" echo strFmtDate=Right(Year(strLastDate),4) ^& Right("0" ^& Month(strLastDate),2) ^& "01"
>>"%temp%/DateCalculate.vbs" echo WScript.Echo strFmtDate
for /f %%a in ('cscript /nologo "%temp%/DateCalculate.vbs"') do (
set "DstDate=%%a"
)
set DstDate=%DstDate:~0,4%-%DstDate:~4,2%-%DstDate:~6,2%
echo,%DstDate%
pause