derekshull Posted October 6, 2012 Author Share Posted October 6, 2012 I'm getting this becasue its a date now...not an array correct? Quote Link to comment Share on other sites More sharing options...
Barand Posted October 6, 2012 Share Posted October 6, 2012 Don't use NOW() when comparing with a date value. NOW() contains a time element (so 2012-10-06 != 2012-10-06 22:35:40). Use CURDATE() instead. Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 6, 2012 Share Posted October 6, 2012 Don't use NOW() when comparing with a date value. NOW() contains a time element (so 2012-10-06 != 2012-10-06 22:35:40). Use CURDATE() instead. Thanks. OP: See the link in my signature for your error. Quote Link to comment Share on other sites More sharing options...
derekshull Posted October 6, 2012 Author Share Posted October 6, 2012 I changed it to CURDATE() and it still throws off the error :-/ Quote Link to comment Share on other sites More sharing options...
derekshull Posted October 6, 2012 Author Share Posted October 6, 2012 I'm guessing you're stumped and thats why I was given the link. Quote Link to comment Share on other sites More sharing options...
Barand Posted October 6, 2012 Share Posted October 6, 2012 Have you changed your dates to type DATE, format 2012-10-06? The format you were using (06102012) is as much use as a chocolate teapot for date comparisons eg 07102011 > 06102012 Quote Link to comment Share on other sites More sharing options...
derekshull Posted October 6, 2012 Author Share Posted October 6, 2012 I actually figured out what was wrong. While it wasn't really where I was being led I stared at if for a few minutes and it came to me. Thanks for all the help! Quote Link to comment Share on other sites More sharing options...
Barand Posted October 6, 2012 Share Posted October 6, 2012 And the answer was......? Quote Link to comment Share on other sites More sharing options...
derekshull Posted October 6, 2012 Author Share Posted October 6, 2012 $query = 'SELECT * FROM needs WHERE completiondate = DATE_ADD(CURDATE(), INTERVAL 2 DAY)'; $result = mysql_query($query); while ($rows = mysql_fetch_array($result)) { mail ('email@derp.com', 'Subject', 'Body'); } for starters there should have been an _ between DATE and SUB. But then DATE_SUB was wrong. I'm needing the script to see if its two days away and remind me two days in advance. So instead of DATE_SUB you need DATE_ADD. Jessica put me on the right path though. Thanks for teaching me Jessica. And thanks for your help Barand! Quote Link to comment Share on other sites More sharing options...
Barand Posted October 6, 2012 Share Posted October 6, 2012 I never bother with DATE_ADD or DATE_SUB. I find it much easier to use something like ... WHERE completiondate = CURDATE() + INTERVAL 2 DAY Quote Link to comment 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.