I have a database that I want to pull only certain rows that have dates in specified ranges. I'm not sure how to do this properly in active record. Right now it looks like I'm running a standard mysql query inside of an active record query. I hope this gives you the idea of what I'm looking for.
I would also like to be able to get rows with anything before today, including today and 3 days in the future.
$query = $this->db->query("SELECT * FROM 'topics_list' . 'topic date' WHERE DATE(order_datetime) BETWEEN '2012-10-01' AND '2012-10-3'");
You can specify you $where and use active records
$this->db->group_start()
->or_where("product_order.generate_date >= ","$start_date")
->or_where("product_order.generate_date <","$end_date + INTERVAL 1 DAY")
->group_end();
You can specify you $where
and use active records
$where = "DATE(order_datetime) BETWEEN '2012-10-01' AND '2012-10-3'";
$this->db->where($where)->get('table_name');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With