[thelist] MYSQL: getting distinct dates from a DATETIME field

M.G.Noriega manuel at simplelogica.net
Thu Oct 2 13:27:42 CDT 2003


Dunstan Orchard wrote:

>Hi there,
>
>Given the following dates (stored in the DATETIME fields of three seperate
>records) can anyone tell me how I can alter my MYSQL query to return records
>with distinct dates - while ignoring the hour:min:sec bit?
>
>2003-05-15 16:00:00
>2003-05-16 08:00:00
>2003-05-16 16:00:00
>
>$query = "SELECT DATE_FORMAT(event_date, '%b %D') AS event_dates, event_cost,
>event_name FROM event ORDER BY event_date ASC";
>
>  
>
Excuse me if i'm a little dull (just today ;) but won't SELECT DISTINCT do?
As in
$query = "SELECT DISTINCT DATE_FORMAT(event_date, '%b %D') AS 
event_dates, event_cost, event_name FROM event ORDER BY event_date ASC";

-- 
Manuel González Noriega
Simplelógica, construcción web @ http://simplelogica.net
Logicola es el weblog de Simplelógica http://simplelogica.net/logicola/




More information about the thelist mailing list