I'm fighting with mysql and don PHP because they do things that I do not understand. I have a table that has these fields:
id bigint(20)
tit_eve varchar(200)
fec_dde date
fec_hta date
organiz varchar(200)
I do this query ...
SELECT
id,
DATE_FORMAT(fec_dde, '%d-%m-%Y') AS fec_dde,
DATE_FORMAT(fec_hta, '%d-%m-%Y') AS fec_hta,
tit_eve,
organiz
FROM eventos
WHERE (fec_hta >= '10-07-2017') AND eve_apr = 1 ORDER BY fec_hta
returns ANYTHING !!! In PHP I assemble the following:
date_default_timezone_set("America/Buenos_Aires");
$diaActual = date("d-m-Y");
echo $diaActual;
$sql = "SELECT id, DATE_FORMAT(fec_dde, '%d-%m-%Y') AS fec_dde, DATE_FORMAT(fec_hta, '%d-%m-%Y') AS fec_hta, tit_eve, organiz FROM eventos WHERE (fec_hta >= '$diaActual') AND eve_apr = 1 ORDER BY fec_hta DESC";
echo $sql;
$resultado = $mysqli->query($sql);
Although the date I compare is today: 07-10-2017 this query brings me dates of 07-03-2017 and does not order anything ... I do not know what to do !!!
PS: PHP ignores until the order by ID !!! neither ascending nor descending ...