Score:1

How to calculate the sum of duration in a view?

cn flag

How to calculate the sum of duration in a view ? I would like to know the total duration of an album after having entered the duration of each track on the disc. I use the Duration field and Views Aggregator Plus modules. The "duration" format is native in excel spreadsheets for example. Thank you in advance for your help.

Hodba Khalaf avatar
eg flag
Can you be more specific? Do you have 2 date fields and you're calculating duration or you're adding/substracting 2 date fields?
id flag
I think they want to sum floating point numbers that represent time durations.
id flag
57:00 + 3:05 = 1:00:05
Jipi avatar
cn flag
Yes @cilefen, I want to sum time duration (not date) like MM:SS + HH:MM:SS
ru flag
I highly doubt you'll find a solution without writing your own custom code. This module stores the duration as a ISO8601 duration string, and as far as I know SQL databases (and therefore views module) don't know how to handle those strings.
Jaypan avatar
de flag
The module also stores durations in seconds (https://git.drupalcode.org/project/duration_field/-/blob/8.x-2.x/src/Plugin/Field/FieldType/DurationField.php#L67), so that field could potentially be summed up instead of the date string.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.