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 #185600 is a reply to message #185599] Sat, 19 April 2014 19:50 Go to previous messageGo to previous message
Lew Pitcher is currently offline  Lew Pitcher
Messages: 60
Registered: April 2013
Karma:
Member
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';

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
--
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request
[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: Thu Nov 28 02:59:43 GMT 2024

Total time taken to generate the page: 0.03946 seconds