over9k Posted December 24, 2009 Share Posted December 24, 2009 SELECT * FROM `schedule` WHERE `date`='2010-01-01' also tried: SELECT * FROM `schedule` WHERE `date`='2010-01-01 *' SELECT * FROM `schedule` WHERE `date`='2010-01-01 *:*:*' I'm trying to get all records from a certain day disregarding the time portion but the above code is only returning one record when there are many records for a particular day A record looks something like: [pre] id date 0000 0000-00-00 00:00:00 [/pre] The date field is type datetime MySQL server version -- 5.1.30 Quote Link to comment https://forums.phpfreaks.com/topic/186228-query-all-records-with-a-particular-date/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 24, 2009 Share Posted December 24, 2009 SELECT * FROM `schedule` WHERE DATE(date) ='2010-01-01' Quote Link to comment https://forums.phpfreaks.com/topic/186228-query-all-records-with-a-particular-date/#findComment-983512 Share on other sites More sharing options...
over9k Posted December 24, 2009 Author Share Posted December 24, 2009 Thanks PFMaBiSmAd, it worked perfectly I just found the mySQL date functions. I have a second question: Is there any problem with using datetime type as a primary key if the only precision needed is to the minute? Quote Link to comment https://forums.phpfreaks.com/topic/186228-query-all-records-with-a-particular-date/#findComment-983513 Share on other sites More sharing options...
fenway Posted December 27, 2009 Share Posted December 27, 2009 PKs should usually be integers. Quote Link to comment https://forums.phpfreaks.com/topic/186228-query-all-records-with-a-particular-date/#findComment-984600 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.