I have a string date of "July 14, 2018
" from MySQL database. I just want to convert it to date
format because I think my query doesn't recognize it. I have this sample code below:
$res=mysqli_query($conn,"SELECT SUM(price) as INCOME,DATE_FORMAT('%Y-%m',trans_date) as Date
from transactions where status='Paid'
GROUP BY DATE_FORMAT('%Y-%m', trans_date)");
while($row=mysqli_fetch_array($res))
{
$income = $row['INCOME'];
$date = $row['Date'];
$formattedincome = number_format($income, 2)."<br>";
echo "₱".$formattedincome;
echo $date;
}
When I tried to run the query on phpmyadmin
, the Date
column was NULL
.
Hope it is possible. Thank you in advance.