Feign Feign - 5 months ago 8
SQL Question

How to convert a mysql datetime column to just date?

Here is an explanation of how my table is set up (in sqlfiddle)
http://sqlfiddle.com/#!2/86a54d/2

Basically, I have two columns. One is a varchar and contains a name. The other is a datetime and contains a certain date with a time.

I want to select rows where the date in the datetime matches today's date. I have tried things like...

select * from alerts_to_send where date_to_send = now()
select * from alerts_to_send where date_to_send = curdate()


I'm not exactly where to go from here... Any ideas would be greatly appreciated :)

Just to re-clarify, I want to select the rows where today's date matches the date part of my datetime type column.

Answer

try this

  select * from alerts_to_send 
  where  DATE_FORMAT(date_to_send,'%m-%d-%Y') = DATE_FORMAT(now(),'%m-%d-%Y')

fiddle