I was very happy to find this module today. Thanks for making it available!

I could use some advice on how to get this done. I have a field list view that shows a link and a date using the date module. I'd like to group by list by the year in the date. Is this possible, or will I have to create another field for just the year? The goal is to make the output look something like this:

2009

  • Some link text
    May 1, 2009
  • Another link
    February 1, 2009

2008

  • Here goes a link
    December 1, 2008
  • Another example link
    July 1, 2008

Thanks for your time to help me out.

Comments

nrackleff’s picture

subscribing. This is something that I need to know how to do too...for press releases.

primsi’s picture

Subscribing

Critter’s picture

Subscribing. I really don't want to create a date field in my content type just for the year in order to group the view by that year field, but if that's what we have to do, so be it.

Critter’s picture

I found a very simple and elegant solution that worked for me. See this link: http://groups.drupal.org/node/24508

Thanks to "shifthappens" for the solution, give credit where credit is due. Hope this helps the rest of you.

Here are the details:

Create two new date formats (Admin >> Site Configuration >> Date and Time >> Formats >> Custom Formats), one called date_only (try this custom format: l F d, Y) and another called time_only (try this custom format: g:i A). You need to create the new name and its format separately, and then 'assign' the format to the name.
Refresh your site cache (Admin >> Site Configuration >> Performance --- clear cached data). This is necessary for these two new date formats to be available when creating your view.
Now go back to the view that you created.
Change your current date field to the time_only format.
Add a second date field (that's right, the exact same field a second time). This time select 'exclude from display' and set the format of this field to date_only
OK, now go back to your grouping field settings and group by the "date_only" field, not the time_only field.
Click save
OK, this should now give you the grouping that you want, grouping events by day, displaying the date_only field as the grouping title and the time_only field next to each event within that day.

Bonus points - if you create this view by cloning the "date_browser" view, you will be able to add date browser navigation at the top of your view to scroll back and forth between months.

I wrote this by memory, so hopefully I didn't miss any steps in the process. If you run into problems, let me know.

akolahi’s picture

Version: 6.x-1.0-rc1 » 6.x-1.x-dev
Component: User interface » Code
Category: support » bug

I believe this may be a bug in Views Group By. It appears as thought Views Group By is not respecting the Date Format, but instead using the raw date. Thus Two fields with September - 2009 are not being grouped together, but are treated as separate since their underlying dates are different.

In order to be useful for date based reports, such as sales per month or articles per year etc, Views Group By needs to respect the Date Format and group based on the format.

marcushenningsen’s picture

I'm not sure this is to be considered a bug. I assume Views Group By is supposed to use whatever it retrieves from the data base, without any formatting. However, I would also like to see a solution on this.

I suppose the solution described in this issue (http://drupal.org/node/572998) would work, but it is clunky, as the author says himself.

irakli’s picture

Category: bug » support
Status: Active » Fixed

marcushenningsen is right - this is not a bug and I assume the solution posted by Critter to be the answer to the issue, closing therefore.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.