Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Any idea how to modify to show only sum of records of today? (not last 24h).

private function get_sum_value_total_spent_receive_today($table, $field){
    if (!get_role("admin")) {
        $this->db->where("uid", session("uid"));
    }
    $this->db->select("SUM(".$field.") as total");
    $this->db->from($table);
    $this->db->where("status", 1);
    $query = $this->db->get();
    $result = $query->result();
    if ($result[0]->total > 0) {
        return $result[0]->total;
    }else{
        return 0;
    }

}


What I have tried:

private function get_sum_value_total_spent_receive_today($table, $field){
    if (!get_role("admin")) {
        $this->db->where("uid", session("uid"));
    }
    $this->load->helper('date');
    $this->db->select("SUM(".$field.") as total");
    $this->db->from($table);
    $this->db->where("status", 1);
    $this->db->set('created', 'NOW()', FALSE);
  $query = $this->db->get();
    $result = $query->result();
    if ($result[0]->total > 0) {
        return $result[0]->total;
    }else{
        return 0;
    }

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900