Get result BETWEEN Two month in CODEIGNITER
HI, welcome in this Codeigniter Tutorial. Here I will discuss a topic to get result use DATE_FORMAT from the database in Codeigniter. Get result between two-month use where clause and month value match from database table field using PHP DATE FORMAT.
Nowadays many Developers want to display user result on their web pages using DATE FORMATE. I also created my new project to fetch data from MySQL table date wise, month wise and year wise form date format. I hope this example code format helps you so much.
If you are looking for such topics on Google, then this tutorial for you. Follow this example code carefully, you can understand.
Here I will give you two example, First is select date BETWEEN two MONTH and second is select data GROUP BY ID with DATE FORMATE month wise:
Get Result Month wise:
<?php public function getResultMonthwise($start_month,$end_month){ $qry=$this->db->select('*')->from( 'Table Name' ) ->where("DATE_FORMAT(column_date,'%m') BETWEEN '$start_month' AND '$end_month' ")->get(); return $data_monthwise=$qry->result(); } ?>
Or Try It:
<?php public function getResultMonthwise($start_month,$end_month){ $qry=$this->db->select('*',COUNT('fk_id'))->group_by('fk_party_id')->from('Table Name') ->select_sum( 'price' )->where("DATE_FORMAT(add_date,'%m') BETWEEN '$start_month' AND '$end_month' ")->get(); return $data_monthwise=$qry->result(); } ?>
Thank for your share
Thank you !
Thanks for sharing, this article will help me a lot in the upcoming projects