Select a record from given year and month. I am doing like this
if ($_REQUEST['thismonth']!=''){
$fromdate = $_REQUEST['thismonth']."-01 00:00:00";
$todate = $_REQUEST['thismonth']."-31 23:59:59";
$fdate=explode('-',$fromdate);
//print_r($fdate);
$year1=$fdate[0];
$month1=$fdate[1];
$date = $year1=$fdate[0]."-".$month1=$fdate[1];
$result=mysql_query("select * from tbl_daily_rpt where date like '%$date%' order by cdate desc");
}
and date format in tbl_daily_rpt table like this way 2017-02-28. when echo a $date value is given a 2017-02. Select all the records which date like this 2017-02
Try this query
SELECT * FROM tbl_daily_rpt where YEAR(`date`) = '2017' AND MONTH(`date`) = '02'