otuatail Posted July 21, 2015 Share Posted July 21, 2015 $sqlAllData = "SELECT * FROM Bank_Data WHERE EntryDate > '" . $StartDate . "' AND EntryDate < DATE_ADD('$StartDate', 6 WEEK) ORDER BY EntryDate ASC, Output"; echo = SELECT * FROM Bank_Data WHERE EntryDate > '20-Jul-2015' AND EntryDate < DATE_ADD('20-Jul-2015', 6 WEEK) ORDER BY EntryDate ASC, Output I copied this from the MySQL site but can't get it to work. Quote Link to comment https://forums.phpfreaks.com/topic/297402-date_add-in-mysql/ Share on other sites More sharing options...
otuatail Posted July 21, 2015 Author Share Posted July 21, 2015 SELECT * FROM Bank_Data WHERE EntryDate > '2015-07-20' AND EntryDate < DATE_ADD(2015-07-20, 6 WEEK) ORDER BY EntryDate ASC, Output Sorry should have reversed the date but it still fails. Now Quote Link to comment https://forums.phpfreaks.com/topic/297402-date_add-in-mysql/#findComment-1516921 Share on other sites More sharing options...
Ch0cu3r Posted July 21, 2015 Share Posted July 21, 2015 You need the INTERVAL keyword before 6 WEEK $sqlAllData = "SELECT * FROM Bank_Data WHERE EntryDate > '" . $StartDate . "' AND EntryDate < DATE_ADD('$StartDate', INTERVAL 6 WEEK) ORDER BY EntryDate ASC, Output"; Quote Link to comment https://forums.phpfreaks.com/topic/297402-date_add-in-mysql/#findComment-1516922 Share on other sites More sharing options...
Barand Posted July 21, 2015 Share Posted July 21, 2015 or instead of the DATE_ADD() function you can just use ... AND EntryDate < '$StartDate' + INTERVAL 6 WEEK Quote Link to comment https://forums.phpfreaks.com/topic/297402-date_add-in-mysql/#findComment-1516938 Share on other sites More sharing options...
Solution otuatail Posted July 22, 2015 Author Solution Share Posted July 22, 2015 Thanks for both of those suggestion. It works now. Quote Link to comment https://forums.phpfreaks.com/topic/297402-date_add-in-mysql/#findComment-1517047 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.