Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Date: Sun, 20 Apr 2014 15:13:14 +0200 From: Luuk User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 Newsgroups: comp.lang.php Subject: Re: select date from DATETIME field References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 26 NNTP-Posting-Host: 2001:980:9089:1:b1ef:e076:9a4f:cd14 X-Trace: 1397999701 news.xs4all.nl 2853 [2001:980:9089:1:b1ef:e076:9a4f:cd14]:58822 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.php:13419 On 19-4-2014 23:44, pentapus wrote: > On 4/19/2014 3:50 PM, Lew Pitcher wrote: >> On Saturday 19 April 2014 15:39, in comp.lang.php, "pentapus" >> wrote: >> >>> I have a DATETIME field that I am looking for rows that just match the >>> date. What is the easy way? >>> >>> I thought SELECT * FROM some_table WHERE DATE(time-date-field) = ... but >>> no go... >> >> Try quoting the target date, as in >> SELECT * from some_table WHERE DATE(time-date-field) = '2014-01-01'; > > Thanks. That works. I'd left out the dashes (in my php date code) when I > changed to DATETIME. Just knowing I had the sql syntax correct was > enough to put me on the right track. >> This would be better: SELECT * FROM some_table WHERE time-date-field between '2014-04-20' and date('2014-04-20') + INTERVAL 1 DAY; Because your database can make use of the index you defined on that field.....