Question : Comparing dates in Windows Batch file

All,
I would like to compare 2 dates in batch file using "IF" operator. But when i put date in 2009 , it doesnot  work to compare with  todats date
 if 07/12/2010 GT 07/12/2009
(do something)
But it never goes to do something.
 However if i put any date in 2010 year it works
eg  if 07/12/2010 GT 06/12/2010
(do something)

Answer : Comparing dates in Windows Batch file

Here's a small example script you can play around with to give you the idea.

~bp
1:
2:
3:
4:
5:
6:
7:
@echo off
set DateIn=01/01/2010
set DateNow=%DATE:~-4%%DATE:~-10,2%%DATE:~-7,2%
set DateCheck=%DateIn:~-4%%DateIn:~-10,2%%DateIn:~-7,2%
if %DateCheck% GTR %DateNow% echo Greater Than
if %DateCheck% LSS %DateNow% echo Less Than
if %DateCheck% EQU %DateNow% echo Equal
Random Solutions  
 
programming4us programming4us