jmrothermel Posted March 1, 2008 Share Posted March 1, 2008 I am doing this directly in MySQL - so its not a PHP coding issue or anything. I have a field that is date date No 0000-00-00 format. I am trying to do this query on it: < DATE_SUB(CURDATE(), INTERVAL 4 DAY Its returning no results - even though I know there is a line in there with the date 2008-01-29. Any suggestions why its not returning the result? Quote Link to comment https://forums.phpfreaks.com/topic/93903-query-not-returning-results-even-though-there-is-data/ Share on other sites More sharing options...
Barand Posted March 2, 2008 Share Posted March 2, 2008 Seeing your whole query might help Quote Link to comment https://forums.phpfreaks.com/topic/93903-query-not-returning-results-even-though-there-is-data/#findComment-481287 Share on other sites More sharing options...
jmrothermel Posted March 2, 2008 Author Share Posted March 2, 2008 That is my whole query. When I go into the database Im going up to search at the top and in the field next to the date I select the "<" carat and type in the search box DATE_SUB(CURDATE(), INTERVAL 4 DAY I then click Go for the results. Quote Link to comment https://forums.phpfreaks.com/topic/93903-query-not-returning-results-even-though-there-is-data/#findComment-481294 Share on other sites More sharing options...
fenway Posted March 2, 2008 Share Posted March 2, 2008 That is my whole query No, it's not. And you're missing a close paren, so it's definitely isn't. Whatever tool you're using should produce a proper query... post it here. Quote Link to comment https://forums.phpfreaks.com/topic/93903-query-not-returning-results-even-though-there-is-data/#findComment-481364 Share on other sites More sharing options...
PFMaBiSmAd Posted March 2, 2008 Share Posted March 2, 2008 If the information you posted in the first post is correct, 2008-01-29 is more than 4 days ago and would not match the query. That date is a little more than 2 months ago. Quote Link to comment https://forums.phpfreaks.com/topic/93903-query-not-returning-results-even-though-there-is-data/#findComment-481385 Share on other sites More sharing options...
jmrothermel Posted March 2, 2008 Author Share Posted March 2, 2008 SELECT * FROM `pets` WHERE `lastfed` < 'DATE_SUB(CURDATE(), INTERVAL 4 DAY' LIMIT 0 , 30 And dates is backwards for whatever reason. If I turn the carat around I get all the results WITHIN the last four days. (2-26 to 3-2) I want all results from before that. So thats definately the carat I want. Quote Link to comment https://forums.phpfreaks.com/topic/93903-query-not-returning-results-even-though-there-is-data/#findComment-481591 Share on other sites More sharing options...
Barand Posted March 2, 2008 Share Posted March 2, 2008 WHERE `lastfed` < DATE_SUB(CURDATE(), INTERVAL 4 DAY) or WHERE `lastfed` < CURDATE() - INTERVAL 4 DAY Quote Link to comment https://forums.phpfreaks.com/topic/93903-query-not-returning-results-even-though-there-is-data/#findComment-481592 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.