title: Batch File If modified date = yesterday date (run command)
body: <p>Ok, I'm using Rob Van der Woude yesterday.bat code along with some code that I've put together with the help of others posts here. </p>
  
  <p>I have a file that I first want to see if it exists with yesterday's date, if true, then I'll do some other stuff.  The problem I am stuck on is comparing the filedate to "yesterday's" date.  When I echo them to screen, they both look exactly the same, but my batch file says they are not.  The first part of code is from yesterday.bat to show where I am inserting my code.  Any guidance is greatly appreciated.</p>
  
  <pre><code>Display the results
  ECHO Format:     YYYYMMDD  (%LocalFormat%)
  ECHO.==================================
  CALL ECHO Yesterday:  %SortYest%  %yLocal%
  ECHO Today:      %SortDate%  %Today%
  
  :: Check if file gams1bu from yesterday exists
  SET filename="B:\data\backup\gams1bu" 
  IF NOT EXIST %filename% GOTO log 
  FOR %%f IN (%filename%) DO SET filedatetime=%%~tf 
  
  ::This displays the results of the two variables
  CALL ECHO %yLocal%
  CALL ECHO %filedatetime:~0,-10%
  
  
  IF %filedatetime:~0,-10% == %yLocal% goto same
  
  goto notsame
  
  :same
  echo Dates the same, do some code here
  
  goto next
  
  :notsame
  echo Dates NOT the same, do some code here  
  </code></pre>
  
  <p>Even though the dates appear identical when I run this, the batch file goes to :notsame  ????  </p>