开发者

mysql date and datetime problem

开发者 https://www.devze.com 2023-02-10 13:40 出处:网络
I have a mysql table called table1.with id and dt columns.The dt is of type datetime. From this, I am trying to extract all id\'s with a specific date (not given the time, just the date, like 2011-02

I have a mysql table called table1. with id and dt columns. The dt is of type datetime.

From this, I am trying to extract all id's with a specific date (not given the time, just the date, like 2011-02-11 say)

I could do it as a between the 00:00:00 and midnight of that date, but is their a pr开发者_运维百科oper way to do it with mysql and php?


SELECT id, dt 
FROM table1
WHERE DATE(dt) = '2011-02-11'

MySQL's got a pretty comprehensive set of Date/Time handling functions, documented here

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号