Reputation: 284
I want to filter current month data but facing a problem:
$months = array(01 => "JAN", 02 => "FEB", 03 => "MAR", 04 => "APR", 05 => "MAY", 06 => "JUN", 07 => "JUL", 08 => "AUG", 09 => "SEP", 10 => "OCT", 11 => "NOV", 12 => "DEC");
$date = getdate();
$month = $date['mon'];
$Month_Name = $months[$month];
echo $Month_Name;
$query = oci_parse($con, "SELECT FIR.*, ACCUSED.* FROM FIR INNER JOIN ACCUSED ON FIR.FIR_NO = ACCUSED.FIR_NO WHERE FIR_DATE = '$Month_Name' ORDER BY FIR_DATE DESC");
Now the problem is that if i do FIR_DATE = '04-$Month_Name-14'
this works beacuse my date format is like 08-MAR-14
but this will not allow me to get month data. Any help would be appreciated.
Upvotes: 0
Views: 179
Reputation: 3858
I am not sure I understood well, but I think this is what you want.
$query = oci_parse($con, "SELECT FIR.*, ACCUSED.* FROM FIR INNER JOIN ACCUSED
ON FIR.FIR_NO = ACCUSED.FIR_NO WHERE
TO_CHAR(TO_DATE(FIR_DATE, 'DD-MON-YYYY'), 'MON')= '$Month_Name'
ORDER BY FIR_DATE DESC");
Upvotes: 1
Reputation: 5981
To get the current month you don't need this.
echo date('M');
will display it in the format you are looking for. More formats are available, you will find them on date() documentation page.
Upvotes: 0