比较2日期在Windows批处理文件 [英] Compare 2 dates in a Windows batch file
本文介绍了比较2日期在Windows批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这怎么可能比较在批处理文件2日期?
这样的:
How is it possible to compare 2 dates in batch files? This:
if %%newdate geq %olddate% _do smth_
不起作用。
在这种情况下,我有结果 2013年5月27日
是比的 2013年7月15日$更大C $ C>和结果
2013年7月14日
是小于的 2013年7月15日
In this case I have that
27.05.2013
is greater than 15.07.2013
and
14.07.2013
is less than 15.07.2013
振亚
推荐答案
试试这个:
set "sdate1=%olddate:~-4%%olddate:~3,2%%olddate:~0,2%"
set "sdate2=%newdate:~-4%%newdate:~3,2%%newdate:~0,2%"
if %sdate1% GTR %sdate2% (goto there) else echo here
这篇关于比较2日期在Windows批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文