Need help with date

$query=“SELECT team1, team2, data,czas,liga,stream,DATE_FORMAT(data, ‘%Y-%m-%d’) FROM table_name where date(data) = curdate()+5;”;
I have this for every day of the week, but there is a one issue. this is the first of March. When you add 5 days to today’s date you will get 1th of March. For some reason I don’t get any records . Does anyone know why?

Unless the forum software mangled what you posted, to do date math, you either need to use DATE_ADD() in the query, or the INTERVAL keyword, i.e. curdate() + INTERVAL 5 DAY

You should run a single query that gets the data you want in the order that you want it. If you have 5-7 repeated sections of code/queries that only differs in the added number of days, this is not efficient coding.

Also, why are you formatting the date with the same format it is already in? If the ‘data’ column is actually a date or date/time value it should be named such.

I found the solution. I’m not a pro :slight_smile: just learning in my free time.
$tomorrow = date(“j F”, strtotime("+ 6 day"));
$query=“SELECT * FROM premier WHERE data = ‘$tomorrow’”;
I have done it this way. I’m not sure if its perfect way but its working.
Thank you anyway dude

Sponsor our Newsletter | Privacy Policy | Terms of Service