0
I’m trying to display a query ordered by month field date, in the phpmyadmin
the query comes out right and when I display the result of the same query with php the date comes out of the correct order.
consultation:
"select calendario.id_calendario, calendario.id_download, eventos.id_evento, eventos.descricao, str_to_date(concat(dia, '/', mes, '/', ano) , '%d/%m/%Y') as data
from calendario
inner join eventos on calendario.id_evento = eventos.id_evento
order by month(data) asc , eventos.descricao asc"
mysql displays like this (correct)
The only difference is that I format the date in php for dd/mm/aaaa
but this is after the consultation, someone has been through this?
It’s not easier just to use one
date_format()
? do not need to convert a date field to date.– rray
There are three int fields (day, month and year) I use so because I have a calendar function that issues payment guides based on the "day" field that anticipates payment dates in the case of Saturdays, Sundays and holidays. And also because the customer wants to enter only with the day in time to register the events, but as I have to keep the registered events for up to 60 days at the time of displaying the listing of events if I do not put the full date there is no way to differentiate a same event that occurred in January from one that occurs in February.
– Sergio Fortes
You are using a CONCAT to join day, month and year, why not use ORDER BY calendar.mes, events.Description?? (I believe that the CSA is not necessary)
– Thiago Santos
Good morning Thiago, really simplifies the query this way and the result is the same, only the queries are not being displayed through php with the same result that comes out in phpmyadmin
– Sergio Fortes
Ideally you put your code in PHP too, because the error should be there.
– Sorack