gevensen Posted December 15, 2009 Share Posted December 15, 2009 Im looking to search back 90 days for example but it only returns say the last 2 weeks, if i increase it i see other records but still not the full number any ideas? SELECT * FROM sc_income WHERE full_name = 'Smith, John' AND date >= CURRENT_DATE - '90' Quote Link to comment https://forums.phpfreaks.com/topic/185218-whats-wrong-with-this-date-query/ Share on other sites More sharing options...
cags Posted December 15, 2009 Share Posted December 15, 2009 I'm guessing that '90' has no quantifiable meaning to MySQL. Minus 90 what? hours, days, months? Quote Link to comment https://forums.phpfreaks.com/topic/185218-whats-wrong-with-this-date-query/#findComment-977752 Share on other sites More sharing options...
bowett Posted December 15, 2009 Share Posted December 15, 2009 You could always try: SELECT * FROM sc_income WHERE full_name = 'Smith, John' AND date >= DATE_SUB(CURRENT_DATE(), INTERVAL 90 DAY) Should have the desired effect but not tested it. Quote Link to comment https://forums.phpfreaks.com/topic/185218-whats-wrong-with-this-date-query/#findComment-977753 Share on other sites More sharing options...
Barand Posted December 15, 2009 Share Posted December 15, 2009 Alternatively, SELECT * FROM sc_income WHERE full_name = 'Smith, John' AND date >= CURDATE() - INTERVAL 90 DAY Quote Link to comment https://forums.phpfreaks.com/topic/185218-whats-wrong-with-this-date-query/#findComment-977840 Share on other sites More sharing options...
gevensen Posted December 16, 2009 Author Share Posted December 16, 2009 ok repeat after me DOYYYYYYYYYY i had the query right originally but used 90 DAYS instead of 90 DAY It didnt work with days do i came up with the next query which i posted thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/185218-whats-wrong-with-this-date-query/#findComment-978189 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.