title: How to get last record by date but a datatype varchar
body: <p>I am trying to fetch data from a table with datatype <strong>varchar</strong>, but I need it to select the last 2 days using where clause by date. </p>
  
  <p>Here I have tried from <a href="https://itsolutionstuff.com/post/how-to-get-last-record-from-mysql-table-in-codeigniterexample.html" rel="nofollow noreferrer">this link</a>:</p>
  
  <pre><code>$query = $this
      -&gt;db
      -&gt;select('*, COUNT(*) as cnt')
      -&gt;where('STR_TO_DATE(created_at,"%d-%m-%Y") &gt;=', '(CURDATE() - INTERVAL 2 DAY)')
      -&gt;group_by('client')
      -&gt;order_by('cnt', 'DESC')
      -&gt;get('histprob');
  </code></pre>
  
  <p>But the result is showing all data on my table instead of only two days passed.
  My column created_at is shown like: <code>06-02-2019 23:00</code></p>