0
Guys, I need to make a select that organizes by date and time. By date it is already working, but if I put an "and" "hour" after the date, it messes up all the records. See my select:
$dados = Connection::select("Select *,id, data, mes,date_format(`data`,'%d/%m/%Y') as `data_formatada` FROM (SELECT Day(data) AS dia, year(data) AS ano, (CASE month(data) when 1 then 'Janeiro' when 2 then 'Fevereiro' when 3 then 'Março' when 4 then 'Abril' when 5 then 'Maio' when 6 then 'Junho' when 7 then 'Julho' when 8 then 'Agosto' when 9 then 'Setembro' when 10 then 'Outubro' when 11 then 'Novembro' when 12 then 'Dezembro' END) AS mes, (CASE WEEKDAY(data) when 0 then 'Segunda-feira' when 1 then 'Terça-feira' when 2 then 'Quarta-feira' when 3 then 'Quinta-feira' when 4 then 'Sexta-feira' when 5 then 'Sábado' when 6 then 'Domingo' END) AS DiaDaSemana, id, data,hora,compromisso,pessoa,local FROM agenda WHERE not (data is null)) as agenda order by data asc"
It’s hard to know what "mess" is, see how to create a Minimum, Complete and Verifiable example
– rubStackOverflow
your date field is a timestamp? with date and time?
– DeRamon
No, they are separated, the date field is "date" and the time field is "time".
– Eduehi