Does anyone know how to build a view that groups the results by Month/Year but can print the results expanded. Take the following dataset:


    Event Name  Event Date
    ----------  ----------
    Event 1     2011-05-01
    Event 2     2011-05-15
    Event 3     2011-05-30
    Event 4     2011-06-04
    Event 5     2011-06-22
    Event 6     2011-07-01
    Event 7     2011-08-16
    Event 8     2012-01-01
    Event 9     2012-01-02
    Event 10    2013-05-15

I would like Views to output that data in the following format:

    May 2011
      Event 1
      Event 2
      Event 3

    June 2011
      Event 4
      Event 5

    July 2011
      Event 6

    August 2011
      Event 7

    January 2012
      Event 8
      Event 9

    May 2013
      Event 10

So the view would not actually be grouped in SQL it just needs to print out the events with headings visually grouped by month and year.

4 Answers 4


I'm not sure if it would be possible to group by month like that, but it would be pretty simple to do this in a template (or a preprocess function).

All you really need to do is to loop through all the rows and check if the event has a new month/year. Each time that happens you add the event date formatted as Month year. This would also give you the flexibility to print the months like fx h3 or whatever fits your site best, instead of relying on the markup views would generate.

  • I've actually already done this in code using EntityQuery and grouping manually. Seems like a real limitation of Views that it can't do this.
    – Camsoft
    May 18, 2011 at 10:37
  • @camsoft Views could have added this, but with the number of different ways it would have to be implemented across SQL servers like MySQL, PgSQL etc, I can see why this isn't added. People do like you do, create the query themselves instead of adding this feature in views.
    – googletorp
    May 18, 2011 at 11:08
  • @googletorp I am new in drupal, can you please answer this drupal.stackexchange.com/q/120546/28667 Jul 10, 2014 at 8:31

You can group by any field, including Month-year. You have to select your date field and customize the output. Then, Views can group on the field, using the "Grouping" options under Format: Settings.

  • To make the video even more fantastic and useful, it could go into the user's next problem: "confusing sorting under each month heading". To add the confusing thing: Add another Post Date field, to be displayed next to the Title, with the custom date format Y-m-d. The blog posts are now presented in a jumbled order. Aug 2, 2012 at 15:48
  • 3
    I didn't watch your video, but if it is not included, you will have to enable "Remove tags from rendered output" to get the grouping to work properly. This has something to do with RDF in core (if enabled). It can mess with grouping if this isn't enabled. Jul 12, 2013 at 18:30

You can do that using Views and have it displayed as a table. Table has an option to group fields.

  • 1
    If grouping by date, sometime we may need to uncheck 'Use rendered output to group rows' option for grouping to work. Mar 7, 2012 at 15:23

In Drupal 7, with Views 3, KarenS recommends disabling the RDF module in Core. That's all that has worked for me. http://drupal.org/node/1253562#comment-4886998

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.