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

Tab Alleman Tab.Alleman at MetroGuide.com
Thu Oct 2 14:25:31 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";

$query = "SELECT DATE_FORMAT(event_date, '%b %D') AS event_dates,
event_cost, event_name FROM event ORDER BY event_date ASC
GROUP BY MONTH(event_date), DAY(event_date);"


More information about the thelist mailing list