Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #13419
| Date | 2014-04-20 15:13 +0200 |
|---|---|
| From | Luuk <luuk@invalid.lan> |
| 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> |
| Message-ID | <aotc2b-aha.ln1@luuk.invalid.lan> (permalink) |
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
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