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

Dunstan Orchard dunstan at 1976design.com
Thu Oct 2 14:36:43 CDT 2003


> >Dunstan Orchard wrote:
> >
> >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";
> >
> >  
> Manuel González Noriega
>
> 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";

Thanks, but no, that doesn't work - it was the first thing I tried since it
seems to make sense (at least to me).

I suppose the DATE_FORMAT is in some way messing it up.

:o/

Anyone else? :o)

---------------------------
Dorset, England
http://www.1976design.com/
http://www.1976design.com/blog/


More information about the thelist mailing list