jawaidpk Posted November 1, 2008 Share Posted November 1, 2008 Hi Friends, I have a task in which I have to fetch a row from database table created on specified date, the problem is that the date stored in db table is actually the integer value of mktime(), and this value will be different for every min in a single day, so how can I write the query which will fetch all the rows created on a given DATE. Lets say if 5 records are created at 01-11-2008 at different times then there will be 5 different values in database table but I need all of them to be fetched with one query. so how can I write the WHERE clause in this situation. Thanks Link to comment https://forums.phpfreaks.com/topic/130963-comparing-dates-with-mktime/ Share on other sites More sharing options...
Jeremysr Posted November 1, 2008 Share Posted November 1, 2008 If I understand it correctly, you could do it like this: $start_date = mktime(0, 0, 0, 1, 11, 2008); $end_date = $start_date + (60*60*24); // Add one day $sql = "SELECT * FROM your_table WHERE the_date >= $start_date AND the_date <= $end_date"; Link to comment https://forums.phpfreaks.com/topic/130963-comparing-dates-with-mktime/#findComment-679847 Share on other sites More sharing options...
Barand Posted November 1, 2008 Share Posted November 1, 2008 WHERE DATE(FROM_UNIXTIME(datecolumn)) = '2008-11-01' Link to comment https://forums.phpfreaks.com/topic/130963-comparing-dates-with-mktime/#findComment-679887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.