本文介绍了在Windows批次中减去月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想进行一次跑步并显示上个月。当我尝试减去月份时,它不会显示月份的最后一天。
I would like to have this run and show the previous month. When I try to subtract the month it makes the last day of the month field not appear.
@echo off
set FirstDay=01
set Month=%date:~4,2%
set Year=%date:~10,4%
if %Month%==01 set LastDay=31 & goto foundate
if %Month%==02 set LastDay=28 & goto foundate
if %Month%==03 set LastDay=31 & goto foundate
if %Month%==04 set LastDay=30 & goto foundate
if %Month%==05 set LastDay=31 & goto foundate
if %Month%==06 set LastDay=30 & goto foundate
if %Month%==07 set LastDay=31 & goto foundate
if %Month%==08 set LastDay=31 & goto foundate
if %Month%==09 set LastDay=30 & goto foundate
if %Month%==10 set LastDay=31 & goto foundate
if %Month%==11 set LastDay=30 & goto foundate
if %Month%==12 set LastDay=31 & goto foundate
:foundate
echo The year is: %Year%
echo The month is: %Month%
echo First day of this month is: %FirstDay%
echo Last day of this month is: %LastDay%
推荐答案
我已经修改了cyberponk脚本,以解决以下错误
上个月是:-1/2020
I've modified script of cyberponk for following error
Previous month is: -1/2020
if "%'yy'%"=="" set 'yy'=%'aa'%
我已添加为修复程序
if %'mm'% LSS 10 set 'mm'=%'mm':~1,1%
这篇关于在Windows批次中减去月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!