title: Comparing a string-date with another string-date in MySql query
body: <p>I'm trying to get entries from MySql server where the dates are <code>&gt; date_begin and &lt; date_end</code></p>
  
  <p>My problem is that the table column "<code>date</code>" is set to <code>VARCHAR</code>, and the string I am comparing it is also directly from an <code>&lt;input type="text"/&gt;</code></p>
  
  <p>The date format ( as string / varchar ) in the mysql table and in the textbox will be <code>DD.MM.YYYY</code></p>
  
  <p>my problem is that if i do </p>
  
  <p>( php code )</p>
  
  <pre><code> $query = "SELECT * FROM table WHERE date&gt;='" . $dateBegin . "' AND date&lt;='" . $dateEnd . "'";
  </code></pre>
  
  <p>the result will be completely random.</p>
  
  <p>I know why this happening so the question is: How can I compare this to get the right result ?</p>
  
  <p>thank you all who can help</p>
  
  <p><strong>UPDATE :</strong> </p>
  
  <p>Now I've tryed this solution, but it also doesn't work.</p>
  
  <pre><code>$query = "SELECT * FROM artikel WHERE STR_TO_DATE(datum, '%d.%m.%Y')&gt;=STR_TO_DATE('" . $_REQUEST['dateTo'] . "', '%d.%m.%Y')" . "' AND STR_TO_DATE(datum, '%d.%m.%Y')&lt;=STR_TO_DATE('" . $_REQUEST['dateTo'] . "', '%d.%m.%Y')";
  </code></pre>
  
  <p>the <code>$_REQUEST['dateFrom']</code> and <code>$_REQUEST['dateTo']</code> came from 2 textboxes and the input is a string like this <code>"05.06.2005"</code>.</p>
  
  <p>in the db-table 'artikel' (german for articles) in the column 'datum' (german for date) the values are VARCHAR's with the same format ( "05.06.2005" ).</p>