🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators sumTime
This page was created by Stephanie on 2025-01-09. Last edited by 62.169.16.147 on 2026-09-12.

The sumTime operator calculates the total sum of time values in a collection. It operates on collections of DateTime, Time, or TimeSpan values and returns the aggregate sum as a TimeSpan.

Syntax

collection->sumTime()

Parameters[edit source]

A collection of DateTime, Time, or TimeSpan values.

Return Type[edit source]

TimeSpan - representing the total duration

Description[edit source]

The sumTime operator calculates the total duration by iterating through a collection of time-related values. For DateTime values, it sums only the time portions; for TimeSpan values, it directly adds the durations.

This operator is particularly useful for:

- Calculating total hours worked across multiple time entries

- Summing durations of tasks or activities

- Aggregating time spans for reporting purposes

Implementation Details[edit source]

sumTime calls through to the Common Language Runtime (CLR) to perform precise time arithmetic, ensuring accurate calculations even when dealing with large datasets or complex time values.

Example:[edit source]

Total hours worked from a collection of time entries:

let timeEntries = Sequence{
  TimeSpan.FromHours(8),
  TimeSpan.FromHours(7.5),
  TimeSpan.FromHours(8),
  TimeSpan.FromHours(6),
  TimeSpan.FromHours(8.5)
}
in
  timeEntries->sumTime()

Result: 1 day 14 hours.

1.14:00:00