Page 1 of 1

Group Date Field

Posted: Fri May 26, 2006 9:13 am
by DanielDrummond2k6
Hi,

I necessary to create one query that it catches the field date of mysql and groups per years and months.

I go to explain better what I need:

I have that to create a list that only consists the months and the years of a table of news.

in this table I the same have some entrances of dates with different days of month, year.

Ex.

2006-01-01
2006-01-02
2006-01-03
2006-02-01
2006-02-02
2006-02-03
...

and i need to output only

2006-01
2006-02
....

Some one cam help-me...thanks

Posted: Fri May 26, 2006 9:26 am
by feyd
An EXTRACT() call combined with GROUP BY or DISTINCT would work.

http://dev.mysql.com/doc/refman/4.1/en/ ... #id2920219

Posted: Fri May 26, 2006 9:29 am
by DanielDrummond2k6
SELECT date_format( Data, "%c-%Y" ) AS data_final
FROM `noticia`
GROUP BY data_final

heheheh

i find the anwser..