Search code examples
phpmysqldatecodeignitercodeigniter-3

displaying dates between in codeigniter php not working


i have a codeigniter website, where i am trying to display some dates using below code:

function searchstatus($clients,$fromdate,$todate,$deliveryboy)
{
    $this->db->where('date >=', $fromdate);
    $this->db->where('date <=', $todate);

    if ($clients) {
        $this->db->like('customer', $clients);
    }
    if ($deliveryboy) {
        $this->db->like('deliveryboy', $deliveryboy);
    }

    $this->db->order_by('date','ASC');
    $query = $this->db->get('delivered');
    return $query->result();
}

my table is like below:

enter image description here

however one date is being missed here '2022-06-22'

can anyone please tell me what could be wrong in here, thanks in advance


Solution

  • I think the issue to displaying dates in between, is in your like() clause, please try bellow code it's work for me.

    $this->db->where("( date >='".$fromdate."' AND date <='". $todate."')");