使用GEQ或LSS比较日期

时间:2016-08-18 17:01:38

标签: batch-file windows-scripting

请参阅当前正在测试的此脚本

:DateQuery
set MigrationDate=01,09,2016
echo DateFormat=%date%
echo dd = %date:~0,2%
echo mm = %date:~3,2%
echo yyyy = %date:~6,4%
Set CurrentDate=%date:~0,2%,%date:~3,2%,%date:~6,4%
for /f "tokens=1,2,3 delims=," %%a in ("%MigrationDate%") do set "d2=%%a%%b%%c"
for /f "tokens=1,2,3 delims=," %%a in ("%CurrentDate%") do set "d1=%%a%%b%%c"
echo %d2%,%d1% >C:\temp\Date.txt
goto:Checks

:Checks
if %d2% GTR %d1% echo %d2%,%d1% Greater Than >C:\temp\gtr.txt
if %d2% LSS %d1% echo %d2%,%d1% less >C:\temp\lss.txt
if %d2% EQU %d1% echo %d2%,%d1% equal >C:\temp\equ.txt

麻烦的是我使用01,09,2016作为部署特定文件的迁移日期....但是在测试中它将01/09/2016视为比今天更短的日期18,08,2016

我使用了示例测试文件,它只是用

输出到LSS

01092016(小于)18082016

显然这是不正确的,你能帮忙吗?

谢谢

米高扬

0 个答案:

没有答案