If Date not equal to today then run a command??
Posted: 27 May 2013 03:44
Hey all,
I have a variable which has stored the modification date of a file in the format MM/DD/YYYY (ie. 05/27/2013) What I am trying to do is compare the date to today's, and if it is not the same then run a command. I am not sure how to do this because Windows stores the variable %date% as "Day MM/DD/YYYY" (ie. Mon 05/27/2013)
If I try to compare my variable to %DATE% it always comes back false.
example...
I know this is super simple, I just do not know how to grab part of a variable. Any help would be awesome!
I have a variable which has stored the modification date of a file in the format MM/DD/YYYY (ie. 05/27/2013) What I am trying to do is compare the date to today's, and if it is not the same then run a command. I am not sure how to do this because Windows stores the variable %date% as "Day MM/DD/YYYY" (ie. Mon 05/27/2013)
If I try to compare my variable to %DATE% it always comes back false.
example...
Code: Select all
if %myvar%=%date% echo "File has been updated today" else (Run Command Here)
I know this is super simple, I just do not know how to grab part of a variable. Any help would be awesome!