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

Dunstan Orchard dunstan at 1976design.com
Thu Oct 2 12:44:05 CDT 2003


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";


I currently get this returned:

Date 	        Cost 	Name
May 15th 	$25 	Exhibit Hall Open
May 16th 	$25 	Exhibit Hall Open
May 16th 	$25 	Exhibit Hall Open


I'd like this:

Date 	        Cost 	Name
May 15th 	$25 	Exhibit Hall Open
May 16th 	$25 	Exhibit Hall Open
event_cost, 

Thanks very much,

- Dunstan

p.s. My MYSQL can't do sub-queries.

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


More information about the thelist mailing list