Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

My query to get data by month

$this->db->select('vehicle_make_and_model');
$this->db->join('tukai_drivers','tukai_drivers.driver_id=reqn_challans.dc_driver_id','left');
$this->db->where('dc_challan_date','MONTH(2)');
$this->db->order_by('dc_challan_id','desc');
$result=$this->db->get('reqn_challans')->result();

I am trying it via codeignitor like this

$this->db->where('dc_challan_date','MONTH(2)');

It did not work? What is wrong

Storing date like this

http://awesomescreenshot.com/0424q72ne5

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
925 views
Welcome To Ask or Share your Answers For Others

1 Answer

You need to update your where condition from

$this->db->where('dc_challan_date','MONTH(2)');

to

$this->db->where('MONTH(dc_challan_date)','2');

The actual function is like MONTH(date) so here you have MONTH(dc_challan_date) which is your column name


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...