title: Comparing two date strings in bash
body: <p>I am having trouble with a script that checks the date of a table to make sure the slave's data is up to date</p>
  
  <p>The problem is that the date equality is coming back incorrect:</p>
  
  <pre><code>NOW=$(date +"%Y-%m-%d")
  VALUE=`mysql -uroot -p database -e "select DATE_FORMAT(create_date,'%Y-%m-%d') as '' from actions order by id desc limit 1"`
  echo $NOW $VALUE
  if [ "$?" -ne 0 ]; then
     MSG="MySQL check data date failed"
     echo $MSG
     echo $MSG &gt; $MESSAGE
     /bin/mail -s "$SUBJECT" "$EMAIL" &lt; $MESSAGE
     exit 7
  fi
  if [ "$NOW" != "$VALUE" ]; then
     echo "not equal"
  fi
  </code></pre>
  
  <p>The output is that they are not equal:</p>
  
  <p>2011-12-08 2011-12-08<br />
  not equal<br /></p>
  
  <p>My guess is that I am comparing two different types, but according the bash documentation that shouldn't be the case.
  Can someone explain this to me?
  Thanks</p>