I've seen a number of related issues that seem to eliminate this possibility of getting something done in the short term by confusing it with multigrouping fields (http://drupal.org/node/284545) which I agree is a can of worms.

A problem I see is that, right now, grouping by a date field is virtually useless unless you have a use case with groups of simultaneous events or your granularity on your datetime fields is so rough that you can do it that way. Most of my datetime fields have times on them which keeps me from easily grouping them by day or month.

(I haven't tried this yet but I imagine there's a reasonable work-around for this. We should be able to create a computed field to create a secondary field which would limit the granularity of a datetime field or even create the multigrouping fields http://drupal.org/node/284545 needed to group in some other way.)

But what I'm talking about is much simpler than that. What I see is an opportunity to offer a high level of date grouping functionality for a broad range of use cases by simply letting users choose a single level of granularity to use when grouping by a date field. Maybe something like this wouldn't need to be put off indefinitely. I for one instinctively go to group by date on an almost daily basis and then I remember that doing so is going to give me a separate group for each record.

Comments

dawehner’s picture

Category: feature » support
Status: Active » Fixed

This grouping is done on the actual output level, so it's basically impossible to bring some custom logic into it.

But you could fix it by using a hidden field which renders for example only the quarters.

matslats’s picture

Derene I don't understand what you mean by
a hidden field which renders for example only the quarters
Since the grouping is done by retrieved value, not rendered value, is it possible to retrieve the day or week or month from a unixtime field, then group by that?
Thanks

neopoet’s picture

This is especially bad when you use the node created date: "GROUP BY node_created" is added to the query, which I believe groups by the unix time stamp.

Can we adapt the code in handlers/views_handler_sort_date.inc which already handles granularity?

Status: Fixed » Closed (fixed)

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

Jaapx’s picture

Zany made a workaround with a module: http://drupal.org/project/views_date_format_sql, maybe this module contains a useful example for creating a solution in views?

At this moment I cannot use this module because I cannot find the promised choice for sql in my recent dev version of views. Maybe a bug, maybe I searched on the wrong place.

Jaapx’s picture

Status: Closed (fixed) » Active
Kars-T’s picture

Status: Active » Fixed

Hi

I am closing this issue to clean up the issue queue. Feel free to reopen the issue if there is new information and the problem still resides. If not please make sure you close your issues that you don't need any more.

Maybe you can get support from the local user group. Please take a look at this list at groups.drupal.org.

Status: Fixed » Closed (fixed)

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

robby.griffin’s picture

Status: Closed (fixed) » Active

I'm reopening this because no solution has yet been arrived at. I'm all in favor of a clean issue queue, but this would be a very good feature.

merlinofchaos’s picture

Status: Active » Closed (won't fix)

See http://drupal.org/project/views_daterange

While I'm aware that the module hasn't been updated to D7, upgrading that module is the solution, not trying to add it to Views.

jenlampton’s picture

Project: Views (for Drupal 7) » Date
Version: 7.x-3.x-dev » 7.x-2.x-dev
Component: Miscellaneous » Code
Category: Support request » Feature request
Issue summary: View changes
Status: Closed (won't fix) » Active

Adding a date range argument (or filter) will not solve the "group by" problem mentioned in the initial issue. The problem is that granularity is not taken into account, so you can't for example, group events by day - unless they all happen at the same second.

I think this issue may be better handled in the date queue - since there is a 'Date views" module that would be a good place for the solution. Moving it over there (but leaving open, since it is still unresolved).

kasiawaka’s picture

If I understand correctly, we are looking to group the view results by the date field, but in several stages, so the output would be:
October 2014
- Tuesday, Oct 14, 2014
-- Event 1
-- Event 2
- Wednesday, Oct 15, 2014
-- Event 3
November 2014
- Monday, Nov 3, 2014
-- Event 4
-- Event 5

etc.

The way we did it was:
1. Create a content type with one date field, collect both start and end date, and set granularity to what you need (we had it up to hours and minutes).

2. Create a view. Add that date field as many times as many groupings you need (so, for example, if the list is to be grouped by month first and then a day, add that date field twice). If you also want to display the time of the event next to the event details, add the same date field one more time.

3. For each of the date fields in the view, select proper date formatting you want to use (so for the date field that is suppose to display a month only, select such formatting to display as a date). If needed, create extra formatting under site Configuration > Regional and Language > Date and time.

4. Confirm that the fields looks like they are suppose to, ie. the month field displays with month and year only, the day field displays the name of the day + the date etc. At this point you will be getting duplicate results in the list because the grouping is not working yet.

5. Now, the magic.
Go to the view settings (under Format > Settings for the format you are using) and select to group by fields. Start from the highest grouping, so in our example first group by the field that is representing the month and then group by date field that has a day in it. IMPORTANT: checkbox both options: "Use rendered output to group rows" and "Remove tags from rendered output"

That worked for us, hope it helps,
Kasia

graysonecooper’s picture

Status: Active » Closed (works as designed)

#12, step 5 did the trick for me!

DamienMcKenna’s picture

Component: Code » Documentation
Category: Feature request » Task
Status: Closed (works as designed) » Active

Let's make this a documentation task.