user1241438
user1241438

Reputation: 1543

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?

Upvotes: 0

Views: 75

Answers (2)

GTSouza
GTSouza

Reputation: 365

Change here:

7/15/2012

to:

07/15/2012

Upvotes: 3

ruakh
ruakh

Reputation: 183251

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?)

Upvotes: 1

Related Questions