I want to get count
of today on-contracted generators
. I used where condition for start date and end date with today date, So i get count of on-contract generators when reaching start date and end date to today date. But I need to get count of on-contract generators when today date between start date and end date.
Example:- Generator booked from RA_start date: 06-09-2018 to RA_end date: 08-09-2018
, I want to get the count of on-contract generators even when reach date to 07-09-2018. now i am getting count only RA_start date: 06-09-2018 and RA_end date: 08-09-2018.
Thank you
My Model
public function getToday_OncontractGenerator_count(){
$today = date('Y-m-d');
$this->db-> select('count(generator_id)as total_count');
$this->db->from('generators');
$this->db->join('rental_agreement','generator_id =generator_id_fk');
$this->db->where('Rental_status',1);
$this->db->where("RA_start_date", $today);
$this->db->or_where("RA_end_date", $today);
$query = $this->db->get();
return $query->result();
}
Try with this tweak :-
$today=date('Y-m-d');
$between="'$today' between RA_start_date and RA_end_date";
$this->db-> select('count(generator_id)as total_count');
$this->db->from('generators');
$this->db->join('rental_agreement','generator_id =generator_id_fk');
$this->db->where('Rental_status',1);
$this->db->where($between);
$query = $this->db->get();
return $query->result();