Help summing up a TV watched times by date in dataviewjs

Just because it came up recently and it seems not everyone is aware, you can use human-readable durations in your properties, and Dataview can still sum them up:

image

And the code to sum them up and display the total time is very straightforward:

```dataviewjs
let totalDuration = Duration.fromMillis(0) // create a new duration

totalDuration = totalDuration.plus(dv.current().tv_time_1)
totalDuration = totalDuration.plus(dv.current().tv_time_2)

dv.paragraph('Total time: ' + totalDuration.toFormat("h 'hours and' m 'minutes.'"))
dv.paragraph('Total minutes: ' + totalDuration.as('minutes'))
```
1 Like