Problems with MYSQL date

0

I have to query the mysql database but I have a problem with my query.

In my bank I have 3 string fields, being a day, month and year. These are not dates, but varchar. Okay. I can not change that because I got this seat anyway. I want to get dates equal to or greater than today. The bid that when it queries the next month, it does not take the date of the beginning of the month, but the date with the day equal or greater than today.

SELECT *,(str_to_date(CONCAT(agenda.year,'-',agenda.month,'-',agenda.day), '%Y-%m-%d')) as dta 
FROM agenda 
WHERE  agenda.day >= 26 
AND  agenda.month >= 04 
AND  agenda.year >= 2016 
ORDER BY  (str_to_date(CONCAT(agenda.year,'-',agenda.month,'-',agenda.day), '%Y-%m-%d'))  
LIMIT 6

He returns me until May, but then he picks up the day 26-05 and not before. Is there any way or function to improve this? Any help will be welcome. Sincerely

    
asked by anonymous 26.04.2016 / 14:47

1 answer

0

Hello,

Test this select.

SELECT *,
        (str_to_date(CONCAT(agenda.year,'-',agenda.month,'-',agenda.day), '%Y-%m-%d')) as dta 
from agenda WHERE  agenda.day >= 26 and  "agenda.month >= 04 and  agenda.year >= 2016" 
ORDER BY  (str_to_date(CONCAT(agenda.year,'-',agenda.month,'-',agenda.day), '%Y-%m-%d'))  LIMIT 6
    
26.04.2016 / 14:51