tags:

views:

23

answers:

1

Hi guys, I have a database with date field is this format "2010.06.11. | 10:26 13"

What is need is a php array that would hold all the different dates, .i.e.

array[0] = "2010.06.09."

array[1] = "2010.06.10."

array[2] = "2010.06.11."

Currently I am doing it by selecting the whole table, then looping through the result and adding the date substr to an array if it is not already there.

But maybe there is a faster way? Thanks.

+2  A: 

You can directly select only the distinct dates from the database:

SELECT DISTINCT SUBSTRING(date, 1, 11) AS date_string FROM table
kemp
thanks for the answer. "SELECT DISTINCT (TIME) FROM..." works great by filtering out the events with the same time. Yet "SELECT DISTINCT SUBSTRING(TIME, 1, 11) FROM..." somehow seems to go into a forever loop and doesn't give any results...
tried "SELECT DISTINCT(LEFT(TIME, 11)) FROM..." also won't give any results.
GOT IT! THANKS MAN! I JUST HAD TO USE $row1['LEFT(TIME,11)'] WHEN GOING THROUGH RESULTS.
Ah now I see what you mean, just add an alias to the query, see my edit
kemp