title: Compare dates (stored as string) in android sqlite database?
body: <p>I store dates as <code>String</code> in my database, in this format:</p>
  
  <pre><code>YYYY-MM-DD HH:MM:SS
  </code></pre>
  
  <p>which is one of supported formats (<a href="http://www.sqlite.org/lang_datefunc.html">http://www.sqlite.org/lang_datefunc.html</a>). Now I want to compare these stored dates (well, strings) with another dates. My dates are stored in column <code>column_date</code>, so I'm trying this:</p>
  
  <pre><code>SELECT  * FROM MyTable
  WHERE 
  (Date(column_date) &gt;= Date (2000-01-01) AND Datetime(column_date) &lt;= Datetime (2050-01-01))
  </code></pre>
  
  <p>As i read documentation, <code>The date and time functions use a subset of IS0-8601 date and time formats. The date() function returns the date in this format: YYYY-MM-DD.</code> so I suppose, I'm doing it right - I create date from stored string and compare it with date created from another strings. </p>
  
  <p>But it doesn't work, even when <code>column_date</code> is date from this year, and as u can see the start and end dates are very benevolent. Tried also this (used datetime instead of date):</p>
  
  <pre><code>SELECT  * FROM MyTable
      WHERE 
      (datetime(column_date) &gt;= Date (2000-01-01) AND datetime(column_date) &lt;= Datetime (2050-01-01))
  </code></pre>
  
  <p>and this (use between instead of &lt;= and >=)</p>
  
  <pre><code>SELECT  * FROM MyTable
      WHERE 
      (Date(column_date) between Date (2000-01-01) AND Datetime (2050-01-01))
  </code></pre>
  
  <p>and all other possible combinations. What the hell I'm doing wrong, am I stupid, or the documentaion lies, or I missed something very important? Trying to find solution few hours, but nothing works...</p>