I'm trying to create a table which aggregates all full date (Year-Month-Day) values into the Year. The issue I'm facing is that, even though I managed to achieve that, view still somehow sees day and month of the date field, and shows them as 2 different records.

In the end I'd like to plot that data into the charts module and receive a result of Number of Items vs their Age

These are the screenshots of my view as I have it right now. enter image description here enter image description here

  • Did you create a new date format to show the year only? When using that format in views for the date field, any two dates in the same year will be identical in re to the date field.
    – Paul
    Sep 15, 2016 at 7:17
  • Hi Paul, In my content type I use Year, Month, Day format, which is how I want it to be shown when node is viewed. But in my view I'm using "Time Ago" formatter with interval set to 1. This shows me the age of the nodes, but does not group them. Sep 16, 2016 at 17:50

2 Answers 2


You can use different formatters for the exact same field when you are in a different context. So, while the full node is shown, you can use the full date (as set in CT's Manage Display). When displaying the date in views, you can use the time ago. For correct grouping, add the date field once more, exclude it from display, then set the formatter to a custom one which only shows the year and finally use that rendered output to group the view's rows.


I've run into issues like this in the past. I'm not 100% sure this is correct but you may try this and see if it works for you.

One of the issues of aggregating by dates is that the Views aggregation happens during the database query stage, but the display of "Time ago" happens later, during the rendering stage. Therefore, when the date is converted to "years ago" it's already too late for aggregation.

I've found that Views Date Format SQL has helped me solve this issue in the past. This module...

The Views Date Format SQL module allows to format date fields using SQL. This enables group aggregation for date fields using the choosen granularity.

The core functionality is to remove the date formatting from render() and put it in query(). I.e. format date values using SQL's DATE_FORMAT rather than PHP's format_date. This is achieved by assigning a new default handler to node 'created' and 'changed' date fields. This handler extends and overrides views's build in views_handler_field_date.

Another one to try if that doesn't work is to avoid using Views aggregate option altogether and use a post-query aggregation like Views Aggregator Plus.

  • Can you elaborate more on the way you got it to work with Views Date Format SQL (VDFS)? I'm using DATE module to display date and enabled the VDFS, but it's still not aggregating the way I'd want to see it. I don't think they fully integrated it with DATE yet, since I had to use the DEV release to get the VDFS check mark to appear as per this issue: 1830436 Sep 26, 2016 at 16:49
  • You are right - I used it in combination with the Date Created property of entities, not with Date fields. Have you tried Views Aggregator Plus? I think that may work for your case.
    – argiepiano
    Sep 27, 2016 at 4:52

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.