title: How get date from datetime field in Sqlite ( android )
body: <p>In my app I am storing the creation date and time (of a task) as datetime field in the database.</p>
  
  <p>In one of the activities I am trying to display all the list of tasks created, and
  I need Creation date (just date not datetime) as my first column.</p>
  
  <p>I have used a listview and simple cursor adapater to populate the listview.</p>
  
  <pre><code>private String [] from = { "CREATION_DATE" ,  "_id" , DataBaseHandler.DESCRIPTION };
  private int[] to ={R.id.fh_list_entryDate ,R.id.fh_list_credits, R.id.fh_desc };
  //date string will be in yyyy/mm/dd format.
  fh_cursor= dbHandler.getAllHistory(bun.getString("st_date"),bun.getString("end_date")); 
  dataAdapter = new SimpleCursorAdapter(this,R.layout.full_history_list,fh_cursor,from,to,0);
  listView.setAdapter(dataAdapter);
  </code></pre>
  
  <p>the xml for the "fh_list_entryDate"</p>
  
  <pre><code>&lt;EditText
          android:id="@+id/fh_list_entryDate"
          android:layout_width="120dp"
          android:layout_height="wrap_content"
          android:layout_marginStart="4dp"
          android:inputType="date"
          android:focusable="false"
          android:gravity="center"
          android:textAppearance="?android:attr/textAppearanceMedium" /&gt;
  </code></pre>
  
  <p>in the getAllHistory method the query looks like:</p>
  
  <pre><code>String historyQuery = "SELECT CREATION_DATE , CREDITS _id , DESCRIPTION FROM "+
                      ACTIVITY_DETAILS_TABLE_NAME +
                      " WHERE START_DT &gt; ? "+" AND END_DT &lt; ? ";
  fh_cursor = sqlDB.rawQuery(historyQuery, new String[] {st_date,end_date});
  </code></pre>
  
  <p>If I use the above code I am getting "Tue Jul 01 23:21:05 GMT-04:00 2014" in the first column.</p>
  
  <p>I read about the "strftime"  and I modified the query to:</p>
  
  <pre><code>String historyQuery = "SELECT strftime('%Y-%m-%d', CREATION_DATE) CREATION_DATE, 
                         CREDITS _id , DESCRIPTION FROM "+
                      ACTIVITY_DETAILS_TABLE_NAME +
                      " WHERE START_DT &gt; ? "+" AND END_DT &lt; ? ";
  </code></pre>
  
  <p>Then am getting null instead of date. </p>
  
  <p>My requirement is to display only the date part.  preferably in yyyy/mm/dd format. or yyyy-mm-dd format.</p>
  
  <p>I guess one option is instead of using SimpleCursorAdapter we can iterate over the fh_cursor and coavert the datetime to desrired format using SimpleDateFormat in java code.
  I dont want to do that. Is there a way I can get this my just modifying the query?</p>