Posted by rcharamella on December 18, 2009 at 7:53pm
Hi all,
I've got a View that displays content types sorted by a date field. The Date field contains month, day and year. The sort works fine.
But I'd like to group the listings by Year. I can Group by the date field, but it doesn't give me enough granularity to specify the Year, only the whole date. This creates a "group" for each day. Is there a way that I can get the granularity that I need to group by year only?
Thanks in advance.
Comments
Solution
Thanks to Shifthappens for sending me this solution
Thanks! Here are the full steps
Excelent!
Thank you very much, the solution is really quick and simple. I was looking the way to group a list by date like this:
29/09/2011
1 Item
2 Item
3 Iten
28/09/2011
1 Item
2 Item
3 Item
And this solved my problem!
Greetings
Memoskins
Additional step for this to work in D7/Views3
This solution did not work for me with Views 3 in Drupal 7. It required the additional step of disabling the RDF module in Core, as recommended by KarenS: http://drupal.org/node/1253562#comment-4886998
Thx, csuggs4, after hours of
Thx, csuggs4, after hours of searching for a solution, disabling the RDF module worked for me.
Amazing who would have
Amazing who would have thought RDF module was the culprit...this still works after all these years.
thanks
Thanks
Thanks,
This solution works perfectly - thanks for updating your quesiton with the solution!
Just what I was looking for
Thank you very much agmin. I was reading this http://drupal.org/node/388140 and I couldn't believe that an easy solution wasn't possible. Override the date field output, write php... augh! To much for a rookie ;-) Thanks again.
The Easiest Solution.
The easiest solution is to add a date field to the "Fields" that are used in the View.
For example if you want to group by year, on the post dates of the content, add the Node: Post date field.
In its option choose to Exclude from display" So it won't be shown and set the "Date format" to Custom. Choose 'Y' (without quotes) for the format. It will then only output the year.
If you set the "Style" of the view to "HTML List" you can click the cog-wheel next to it and select a "Grouping field" from the Fields you added to the view. Select the Post date field and you'll see the view being grouped on that field.
Yes, but it seems to work
Yes, but it seems to work only with "native" date fields (like "post date field"), with some custom date fields, you have to disable the RDF module as suggested above. Thanks 4 giving me this suggestion!
no need for RDF disabled (at
no need for RDF disabled (at least with latest views)
under grouping field option you have two options
* Use rendered output to group rows
* Remove tags from rendered output
check both of them
and views grouping will happen with the rendered date field and RDF will not bother ...
GiorgosK
Web development in Greece
Highcharts Module and groupby
I am using the highcharts module and I also would like to group my graph by month. However I can get it to group by day it will not group by month is there any reason why this might be happening ? I am using the date field but it doesnt seem to change anything when I just use month as my data I d appreciate any info that could help.
thanks
That worked for me
Thank you so much for posting that it worked for me after countless hours of search.
Thank you !!!
Sort by
I got to the point that I can group a result set by year. But how can I sort within each group by month? I want to get something like this:
2013
18/01/2013 Bar
01/04/2013 Bar Foo
13/06/2013 Bar Foo Bas
2012
21/05/2012 Bar
30/08/2012 Bar Foo
05/10/2012 Bar Foo Bas
Anybody got an idea?
Sort handler for datetime dates
I created a custom Views sort handler that will add some granularity to a datetime field (Like a Date field :p). This basically resolved my entire issue!
See the file on Pastebin here: http://pastebin.com/XpwVkrZc
Also remember you can edit
Also remember you can edit the view and make sure "Remove tags from rendered output" is turned off if you happen to use RDF.