【方案一】BAT + date.exe(GNU) @echo off rem 调用GNU for Win32的date.exe set "gnuDate=C:/test/date.exe" for /f %%a in ('%gnuDate% "+%%Y%%m01"') do ( for /f %%h in ('%gnuDate% -d "%%a 1 days ago" "+%%Y-%%m-%%d"') do ( set "DstDate=%%h" ) ) echo,%DstDate% pause 【方案二】BAT + VBS @echo off >"%temp%/DateCalculate.vbs" echo strLastDate=DateAdd("d", -DatePart("d", Date), Date) >>"%temp%/DateCalculate.vbs" echo strFmtDate=Right(Year(strLastDate),4) ^& Right("0" ^& Month(strLastDate),2) ^& Right("0" ^& Day(strLastDate),2) >>"%temp%/DateCalculate.vbs" echo WScript.Echo strFmtDate for /f %%a in ('cscript /nologo "%temp%/DateCalculate.vbs"')