Problems with MYSQL data

Asked

Viewed 77 times

0

I have to make a query in mysql database but I have a problem in my query.

In my bank I have 3 string fields, being a day, Month and year. These are not dates, but varchar. Ok. I can’t change that because I took this bank anyway. I want to get the same dates or bigger than today. The bid that when he consults the next month, he 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

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

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
  • Did not roll. I also tried to select as UNIX_TIMESTAMP and it did not work

Browser other questions tagged

You are not signed in. Login or sign up in order to post.