简体   繁体   中英

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'

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 )". Note the zero-padding. So you need to write '07/15/2012' rather than '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?)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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