SELECT rows BETWEEN a date range using CodeIgniter's query builder
I would like to fetch a row which comes into a particular date range.
My raw query:
SELECT *
FROM `table`
WHERE (
(s_tdate <= '2016-05-26' OR `e_expiredate` >= '2016-05-26')
OR (`s_tdate` <= '2017-09-11' AND `e_expiredate` >= '2017-09-11')
OR (`s_tdate` >= '2016-05-26' AND e_expiredate <='2017-09-11')
)
My query builder script:
$this->db->select(*);
$this->db->where("((s_tdate <='$start_date' AND e_expiredate >= '$start_date')");
$this->db->or_where("(s_tdate <='$end_date' AND e_expiredate >='$end_date')");
$this->db->or_where("(s_tdate >='$start_date' AND e_expiredate <='$end_date'))");
$query = $this->db->get('table');
I'm getting no result.