Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #13419

Re: select date from DATETIME field

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 <luuk@invalid.lan>
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 <liuje4$keu$1@news.albasani.net> <BsA4v.247891$h61.112119@fx06.iad> <liuqnl$3ap$1@news.albasani.net>
In-Reply-To <liuqnl$3ap$1@news.albasani.net>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Message-ID <aotc2b-aha.ln1@luuk.invalid.lan> (permalink)
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

Show key headers only | View raw


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"
>> <pentapus@example.com> 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.....

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

select date from DATETIME field pentapus <pentapus@example.com> - 2014-04-19 15:39 -0400
  Re: select date from DATETIME field Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-04-19 15:50 -0400
    Re: select date from DATETIME field pentapus <pentapus@example.com> - 2014-04-19 17:44 -0400
      Re: select date from DATETIME field Luuk <luuk@invalid.lan> - 2014-04-20 15:13 +0200
  Re: select date from DATETIME field Tim Streater <timstreater@greenbee.net> - 2014-04-19 20:56 +0000
    Re: select date from DATETIME field The Natural Philosopher <tnp@invalid.invalid> - 2014-04-19 22:21 +0100
  Re: select date from DATETIME field Denis McMahon <denismfmcmahon@gmail.com> - 2014-04-19 21:01 +0000
    Re: select date from DATETIME field pentapus <pentapus@example.com> - 2014-04-19 17:39 -0400

csiph-web