Page 1 of 1

select distinct date from datetime field

Posted: Sat Mar 19, 2005 11:49 am
by hawleyjr
I have a table that has a field that stores datetime. I would like to run a query that would return distinct dates (days).

For instance, if the field was a date field I would use the following query:

"Select distinct(mydate) from my_table"

Posted: Sat Mar 19, 2005 11:51 am
by hawleyjr
Nevermind I figured it out:


"SELECT DISTINCT DATE_FORMAT(dttm, '%Y-%m-%d') from my_table"

Is this the best way to do it?

Posted: Sat Mar 19, 2005 11:54 am
by phpScott
If it works then yes, is it the best, looks good to me. That is how I would probably end up doing.