PyraX Posted October 7, 2008 Share Posted October 7, 2008 hi im strugling with this SELECT * FROM points WHERE date is today without caring about the time thanks pyrax Quote Link to comment https://forums.phpfreaks.com/topic/127324-solved-mysql-if-datetime-today-question/ Share on other sites More sharing options...
xtopolis Posted October 7, 2008 Share Posted October 7, 2008 Ha, I almost gave you a very slow query, but this one seems to work really fast: Let me know how it works.. SELECT thedate FROM `test` WHERE UNIX_TIMESTAMP(thedate) BETWEEN UNIX_TIMESTAMP(CURDATE()) AND UNIX_TIMESTAMP(DATE_ADD(CURDATE(), INTERVAL + 86399 SECOND)) What does it mean? Convert all datetimes (which I assume you're using) to UNIX_TIMESTAMP equivalents, and check that they are between the unix timestamp of today (at 00:00:00 seconds) and today at (23:59:59) [1 second until tomorrow]. Quote Link to comment https://forums.phpfreaks.com/topic/127324-solved-mysql-if-datetime-today-question/#findComment-658669 Share on other sites More sharing options...
PyraX Posted October 7, 2008 Author Share Posted October 7, 2008 Thanks here was the code I ended up using $sql = "SELECT * FROM points WHERE p_userid = '$_SESSION[uSERID]' AND p_datetime >= '".date('Y-m-d').' 00:00:00'."' AND p_datetime < '".date('Y-m-d').' 23:59:59'."' AND p_type = '1'"; Quote Link to comment https://forums.phpfreaks.com/topic/127324-solved-mysql-if-datetime-today-question/#findComment-658675 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.