title: Select Date From DateTime In Query - Yii2
body: <p>I'm having one event table. In which, <code>due date</code> of event is being stored in <code>datetime</code> format. But, due to some change of requirement, now we need to show only <code>date</code> (excluding time) from <code>due date</code> column. </p>
  
  <p><strong>Event</strong> (Table)</p>
  
  <pre><code>id | user_id | description |       due_date          | is_completed
  
  1      8        My Event1    2016-08-09 19:16:00          0
  2      8        My Event2    2016-08-09 19:53:00          0
  </code></pre>
  
  <p>I wanted to show all event in date wise. Like all event under <code>2016-08-09</code>.</p>
  
  <p>So, I tried with this query.</p>
  
  <pre><code>$upcoming_events = Events::find()-&gt;select(['due_date'])-&gt;distinct()
             -&gt;where(['user_id' =&gt; Yii::$app-&gt;users-&gt;getId(),'is_completed'=&gt; 0 ])
             -&gt;andWhere(['&gt;=','due_date',date("Y-m-d")])
            -&gt;orderBy(['due_date'=&gt;'ASC'])-&gt;limit(5)-&gt;all();
  </code></pre>
  
  <p>But, now 2 dates are being selected as <code>2016-08-09 19:16:00</code> &amp; <code>2016-08-09 19:53:00</code>. Since, date part is not being fetched from select statement. It is showing 2 times same date. </p>
  
  <p><strong><em>var_dump($upcoming_events);</em></strong></p>
  
  <pre><code>[1] =&gt; app\Events Object
    (
      [_attributes:yii\db\BaseActiveRecord:private] =&gt; Array
          (
              [due_date] =&gt; 2016-08-09 19:16:00
          )
    )
  
  [2] =&gt; app\Events Object
  (
  
    [_attributes:yii\db\BaseActiveRecord:private] =&gt; Array
    (
        [due_date] =&gt; 2016-08-09 19:53:00
    )
  )
  </code></pre>
  
  <p>How can I retrieve only date from date time field to get only 1 date in Yii2 Query.</p>
  
  <p>Any help/hint/suggestions is appreciable.</p>