I have a date
field in my MySQL database and it stores the date of type y-m-d
which is already used in other queries, but now I need to capture only the month to make a sum.
The code I have is this
date_default_timezone_set('America/Sao_Paulo');
$datamensal = date('m-d');
$stw = mysql_query("SELECT SUM(valortotal) as total_mensal FROM pedidos WHERE data = '$datamensal'");
But it did not work .... Does anyone know the correct way to perform this action?