newbiePHP Posted October 22, 2007 Share Posted October 22, 2007 Hi Guys, SELECT * FROM `Example` WHERE `DateTime` = "2007-08-28 15:24:44" How do I get my query to find either the above entry or the closest matching one? DateTime column is of course of type DateTime. Any help would be really appreciated. thanks, newbie Quote Link to comment https://forums.phpfreaks.com/topic/74305-query-problem-realting-to-datetime/ Share on other sites More sharing options...
fenway Posted October 22, 2007 Share Posted October 22, 2007 Define "closest". Quote Link to comment https://forums.phpfreaks.com/topic/74305-query-problem-realting-to-datetime/#findComment-375455 Share on other sites More sharing options...
newbiePHP Posted October 22, 2007 Author Share Posted October 22, 2007 well the one that is on the same date and is as close to that time as possible. doesn't matter weather it is before or after that time. If there is an entry in the database that is 2 seconds before query or 5 seconds after the query, you take the closest which would be 2 seconds before it. Quote Link to comment https://forums.phpfreaks.com/topic/74305-query-problem-realting-to-datetime/#findComment-375554 Share on other sites More sharing options...
fenway Posted October 22, 2007 Share Posted October 22, 2007 That still doesn't answer my question... assuming a 30 second "grace period": SELECT * FROM `Example` WHERE `DateTime` BETWEEN '2007-08-28 15:24:44' - INTERVAL 30 SECOND AND '2007-08-28 15:24:44' + INTERVAL 30 SECOND Quote Link to comment https://forums.phpfreaks.com/topic/74305-query-problem-realting-to-datetime/#findComment-375664 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.