Mysql
 sql >> Database >  >> RDS >> Mysql

MySQL ordina per data ma ignora l'anno

Capito:

Rispondi

select b.name, ue.event_title, ue.event_date,
(DAYOFYEAR(ue.event_date) - DAYOFYEAR(CURDATE())) as days
from brains b
join user_events ue on b.user_id=ue.user_id
where b.user_id=63 and 
MOD(DAYOFYEAR(ue.event_date) - DAYOFYEAR(CURDATE()) + 365, 365) <= 30 
order by days asc