如何使用 codeigniter 中的开始日期和结束日期范围获取今天的合同生成器 id 计数?
How to get the today on contract generators count of id using range of start date and end date in codeigniter?
我想获得今天count
的on-contracted generators
。我在 start date 和 end date 的 where 条件中使用了今天的日期,所以我在到达开始日期和结束日期时得到了合同发电机的数量到 今天 。但是我需要在今天日期开始日期和结束日期之间计算合同生成器的数量。
示例:- Generator booked from RA_start date: 06-09-2018 to RA_end date: 08-09-2018
,即使到达日期为 07-09-2018,我也想获取合同生成器的数量。现在我只计算 RA_start 日期:06-09-2018 和 RA_end 日期:08-09-2018.
谢谢
我的模型
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();
}
试试这个调整:-
$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();
我想获得今天count
的on-contracted generators
。我在 start date 和 end date 的 where 条件中使用了今天的日期,所以我在到达开始日期和结束日期时得到了合同发电机的数量到 今天 。但是我需要在今天日期开始日期和结束日期之间计算合同生成器的数量。
示例:- Generator booked from RA_start date: 06-09-2018 to RA_end date: 08-09-2018
,即使到达日期为 07-09-2018,我也想获取合同生成器的数量。现在我只计算 RA_start 日期:06-09-2018 和 RA_end 日期:08-09-2018.
谢谢
我的模型
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();
}
试试这个调整:-
$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();