快活林资源网 Design By www.csstdc.com

【方案一】BAT + date.exe(GNU)

 复制代码 代码如下:
 @echo off
rem 调用GNU for Win32的date.exe
set "gnuDate=C:/test/date.exe"
rem 指定月数
set MonthsAgo=1
for /f %%a in ('%gnuDate% -d "%MonthsAgo% months ago" "+%%Y-%%m-01"') do (
    set "DstDate=%%a"
    )
)
echo,%DstDate%
pause
 

【方案二】BAT + VBS

复制代码 代码如下:
@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

快活林资源网 Design By www.csstdc.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
快活林资源网 Design By www.csstdc.com