FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » select date from DATETIME field
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: select date from DATETIME field [message #185607 is a reply to message #185600] Sat, 19 April 2014 21:44 Go to previous messageGo to previous message
pentapus is currently offline  pentapus
Messages: 3
Registered: April 2014
Karma:
Junior Member
On 4/19/2014 3:50 PM, Lew Pitcher wrote:
> On Saturday 19 April 2014 15:39, in comp.lang.php, "pentapus"
> <pentapus(at)example(dot)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.
>
> Here's an example from something I'm working on...
>
> mysql> select recipe_name, recipe_date from recipe where date(recipe_date)
> = '2014-04-14';
> +--------------------+---------------------+
> | recipe_name | recipe_date |
> +--------------------+---------------------+
> | Beef and Corn Bake | 2014-04-14 20:27:13 |
> +--------------------+---------------------+
> 1 row in set (0.00 sec)
>
> mysql> select recipe_name, recipe_date from recipe where date(recipe_date)
> = '2014-04-03';
> +---------------------+---------------------+
> | recipe_name | recipe_date |
> +---------------------+---------------------+
> | Coffee Rubbed Steak | 2014-04-03 09:14:20 |
> +---------------------+---------------------+
> 1 row in set (0.00 sec)
>
>
> HTH

It did.
>


--
pentapus
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PHP Parse error: syntax error, unexpected '$sql' (T_VARIABLE) in
Next Topic: Use PHP to populate a Mailing list from a webpage
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 23:08:42 GMT 2024

Total time taken to generate the page: 0.06109 seconds