Mysql strip time component from datetime

abarax picture abarax · Nov 6, 2008 · Viewed 92k times · Source

I need to do a date comparison in Mysql without taking into account the time component i.e. i need to convert '2008-11-05 14:30:00' to '2008-11-05'

Currently i am doing this:

SELECT from_days(to_days(my_date))

Is there a proper way of doing this?

Answer

Robert Gamble picture Robert Gamble · Nov 6, 2008

Yes, use the date function:

SELECT date(my_date)