How do I select the date in the Date-Time column?

advertisements

I have a column of type "datetime" with values like 2009-10-20 10:00:00

I would like to extract date from datetime and write a query like:

SELECT * FROM
data
WHERE datetime = '2009-10-20'
ORDER BY datetime DESC

Is the following the best way to do it?

SELECT * FROM
data
WHERE datetime BETWEEN('2009-10-20 00:00:00' AND '2009-10-20 23:59:59'
ORDER BY datetime DESC

This however returns an empty resultset. Any suggestions?


WHERE DATE(datetime) = '2009-10-20'

or try this also and see whether it works on not. Does this helps

WHERE datetime LIKE '2009-10-20%'

You need to check whethere it works on not.