php - Getting data between two date range in codeigniter
Get the solution ↓↓↓I'm trying to fetch data between dates. The date select from date-picker. the formate is like this 04/13/2020 - 04/13/2020 select from date-picker. my query is like this
public function reservation($reservation)
{
$this->db->select("*");
$this->db->from('details');
$this->db->where("DATE_FORMAT(date,'%Y-%m-%d') > '$reservation'");
$query = $this->db->get();
return $query->result();
}
Answer
Solution:
I hope This will work for you
public function reservation($first_date,$second_date)
{
$this->db->select("*");
$this->db->from('details');
$this->db->where("DATE_FORMAT(date,'%Y-%m-%d') >='$first_date'");
$this->db->where("DATE_FORMAT(date,'%Y-%m-%d') <='$second_date'");
$query = $this->db->get();
return $query->result();
}
Answer
Solution:
try this:
$this->db->where("DATE_FORMAT(start_date,'%Y-%m-%d')",'>=',$first_date)
->where("DATE_FORMAT(end_date,'%Y-%m-%d')",'<=',$first_date);
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: composer detected issues in your platform: your composer dependencies require a php version ">= 7.3.0".
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.