2

Please help me, I want to convert a simple SQL statement to Codeigniter

date($fromDate) BETWEEN vehicle_register.start_dt AND vehicle_register.end_dt
3
  • 3
    What you have tried so far? Commented May 10, 2019 at 5:24
  • do you want the method chaining query? Commented May 10, 2019 at 5:26
  • stackoverflow.com/questions/12102195/… Commented May 10, 2019 at 5:32

1 Answer 1

2

Try this with Method chaining,

$this->db->select('*');
$this->db->from('yourTableName');
$this->db->where('date('.$fromDate.') >=', 'vehicle_register.start_dt');
// >= will get conditional date too so please keep it as your reqirement
$this->db->where('date('.$fromDate.') <=', 'vehicle_register.end_dt');
$query= $this->db->get();
if($query->num_rows() > 0){
  //return $query->result();//according to your need
}else{
  //return array();//according to your need
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.