Reputation: 2949
I'm trying to select from table Documents where Date is Today's date. I'm using Codeigniter. But it shows only these documents where there isn't hour. I mean where in database date is: 2015-06-25 00:00:00. But it doesn't display these documents where there is an hour - for example : 2015-06-25 08:34:00. How to display all documents where Date is current date , no matter what is the hour.
<?php
$date = new DateTime("now");
$curr_date = $date->format('Y-m-d ');
$this->db->select('*');
$this->db->from('documents');
$this->db->where('Date', $curr_date);
$query = $this->db->get();
return $query->result();
Upvotes: 3
Views: 20394
Reputation: 38584
Try this
<?php
$date = new DateTime("now");
$curr_date = $date->format('Y-m-d ');
$this->db->select('*');
$this->db->from('documents');
$this->db->where('DATE(Date)',$curr_date);//use date function
$query = $this->db->get();
return $query->result();
Upvotes: 13