从给出/ L参数批量输出日期的列表 [英] Batch to output a list of dates from given for /L parameter
本文介绍了从给出/ L参数批量输出日期的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请考虑以下codeS:
Please consider the following codes:
@echo off
setlocal enabledelayedexpansion
FOR /L %%G IN (0,1,19) DO (
set /a "Dday=%_day%+%%G"
if %mth% equ sml (
if !Dday! gtr 30 (
set "_day=1"
set /a "_month+=1"
)
if !_month! gtr 12 (
set "_month=1"
set /a "_year+=1"
)
) else (
if %mth% equ big (
if !Dday! gtr 31 (
set "_day=1"
set /a "_month+=1"
)
if !_month! gtr 12 (
set "_month=1"
set /a "_year+=1"
)
)
)
echo !Dday!/!_month!/!_year!.txt
)
考虑下面的日期:20/04/2016
Consider the following date: 20/04/2016
_day = 20
; _month = 04
; _year = 2016年
; 总分= SML
;
和我的输出是这样的:
它增加了30天,而不是改变它为1。我可以知道我做了什么错?请指教。谢谢
It increases the day from 30 instead of changing it to 1. Can I know what have I done wrong? Please advise. Thanks
推荐答案
有此脚本中两个问题。首先作为@SomethignDark指出的那样,你需要使用!_天!
,而不是%_一天%
。
There are two problems in this script. First as @SomethignDark pointed out, you need to use !_day!
instead of %_day%
.
二,当 DDAY
大于30, %%摹
是12.所以,你的前pression的!_天!+ %%摹
将是13而不是1。
Second when Dday
is greater than 30, %%G
is 12. So you expression of !_day!+%%G
will be 13 instead of 1.
所以,你需要像
...
FOR /L %%G IN (0,1,19) DO (
set /a "Dday=!_day!+%%G"
if !_day! equ 1 set /a "Dday=!_day!+%%G-12"
...
这篇关于从给出/ L参数批量输出日期的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文