title: MySQL STR_TO_DATE v/s DATE_FORMAT
body: <p>I have a mysql table called test, the structure code is given below</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `test` (
    `id` int(11) NOT NULL,
    `name` varchar(255) NOT NULL,
    `assigned_date` date NOT NULL
  ) ENGINE=InnoDB
  </code></pre>
  
  <p>And the table is containing following data : </p>
  
  <pre><code>INSERT INTO `test` (`id`, `name`, `assigned_date`) VALUES
  (0, 'A', '2012-12-23'),
  (0, 'B', '2012-12-25');
  </code></pre>
  
  <p>Now the problem is when I run the following query it doesn't return me any row.</p>
  
  <pre><code>SELECT name 
  FROM test 
  WHERE 
       DATE_FORMAT(assigned_date, '%m/%d/%Y') &gt;= '12/01/2012'
       AND 
       DATE_FORMAT(assigned_date, '%m/%d/%Y') &lt;= '01/02/2013'
  </code></pre>
  
  <p>But When I use the following commands it returns me two rows as expected.</p>
  
  <pre><code>SELECT name 
  FROM test 
  WHERE
       assigned_date &gt;= STR_TO_DATE('12/01/2012', '%m/%d/%Y')
       AND 
       assigned_date  &lt;= STR_TO_DATE('01/02/2013', '%m/%d/%Y')
  </code></pre>
  
  <p>What is the difference ? Why <strong>DATE_FORMAT</strong> didn't work ?</p>
  
  <p>Please Help with this I have used date_format function through out a site. Now it seems like I have to update the entire site.</p>
  
  <p>Thanks.</p>