简体   繁体   English

mysql查询未返回结果

[英]mysql query not returning results

I am executing this query 我正在执行此查询

SELECT *
FROM temp
WHERE DATE_FORMAT(startTime,'%m/%d/%Y') = '7/15/2012' 

and startTime column has this value '2012-07-15 12:00:00' 并且startTime列具有此值'2012-07-15 12:00:00'

But this is not returning any results. 但这不会返回任何结果。 Can somebody please help? 有人可以帮忙吗?

Change here: 在这里更改:

7/15/2012

to: 至:

07/15/2012

According to the documentation for the DATE_FORMAT function , %m is "Month, numeric ( 00 .. 12 )". 根据DATE_FORMAT函数的文档%m为“月份,数字( 00 .. 12 )”。 Note the zero-padding. 请注意零填充。 So you need to write '07/15/2012' rather than '7/15/2012' . 因此,您需要编写'07/15/2012' '7/15/2012'而不是'7/15/2012'

(And in case you're wondering — I have no idea what month #0 is. So far as I'm aware, the months range from 01 to 12 . Maybe some locales do have a month #0?) (如果您想知道,我不知道#0月份是什么。据我所知,月份的范围是0112也许某些语言环境的月份是#0?)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM