> ## Documentation Index
> Fetch the complete documentation index at: https://docs.farmtrace.co.za/llms.txt
> Use this file to discover all available pages before exploring further.

# Duration functions

> Build elapsed amounts, convert their units, and calculate absolute or remainder values.

A Duration stores elapsed time, not a clock time. Constructors such as `Hours` create durations; converters such as `ToHours` return numbers.

## `Abs`

Returns the non-negative magnitude of a number or duration.

* **Syntax:** `Abs(value)`
* **Requires:** a Numeric or Duration value.
* **Returns:** the same type as the input.
* **Best for:** unsigned differences and normalising reversed intervals.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Abs([Actual Duration] - [Planned Duration])
```

## `Days`

Creates a duration from a number of days.

* **Syntax:** `Days(number)`
* **Requires:** a Numeric value; fractions and negative values are allowed.
* **Returns:** Duration.
* **Best for:** service windows and adding days as elapsed time.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Days(1.5)
```

## `Hours`

Creates a duration from a number of hours.

* **Syntax:** `Hours(number)`
* **Requires:** a Numeric value; fractions and negative values are allowed.
* **Returns:** Duration.
* **Best for:** labour, travel, and operating-time calculations.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Hours([Labour Hours])
```

## `Minutes`

Creates a duration from a number of minutes.

* **Syntax:** `Minutes(number)`
* **Requires:** a Numeric value; fractions and negative values are allowed.
* **Returns:** Duration.
* **Best for:** appointment lengths and short service windows.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Minutes(90)
```

## `Mod`

Returns the mathematical modulus after division.

* **Syntax:** `Mod(dividend, divisor)`
* **Requires:** two Numeric values or two Duration values. The divisor cannot be zero; do not mix numbers and durations.
* **Returns:** Numeric or Duration, matching the inputs.
* **Best for:** repeating cycles where a non-negative result is wanted with a positive divisor.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Mod([Sequence], 7)
Mod([Elapsed], Hours(24))
```

The non-zero result follows the sign of the divisor. This differs from `Rem` for some negative inputs.

## `Rem`

Returns the remainder after division.

* **Syntax:** `Rem(dividend, divisor)`
* **Requires:** two Numeric values or two Duration values. The divisor cannot be zero; do not mix numbers and durations.
* **Returns:** Numeric or Duration, matching the inputs.
* **Best for:** direct remainder calculations that preserve the dividend's direction.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Rem([Sequence], 7)
Rem([Elapsed], Hours(24))
```

The non-zero result follows the sign of the dividend.

## `Seconds`

Creates a duration from a number of seconds.

* **Syntax:** `Seconds(number)`
* **Requires:** a Numeric value; fractions and negative values are allowed.
* **Returns:** Duration.
* **Best for:** precise integration delays and elapsed measurements.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Seconds(2.5)
```

## `ToDays`

Converts a duration to its total number of days.

* **Syntax:** `ToDays(duration)`
* **Requires:** a Duration value.
* **Returns:** Numeric, including any fractional day.
* **Best for:** reports and comparisons expressed in days.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
ToDays([Elapsed])
```

## `ToHours`

Converts a duration to its total number of hours.

* **Syntax:** `ToHours(duration)`
* **Requires:** a Duration value.
* **Returns:** Numeric, including any fractional hour.
* **Best for:** timesheets and labour totals.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
ToHours([Elapsed])
```

## `ToMinutes`

Converts a duration to its total number of minutes.

* **Syntax:** `ToMinutes(duration)`
* **Requires:** a Duration value.
* **Returns:** Numeric, including any fractional minute.
* **Best for:** service-time and appointment reports.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
ToMinutes([Elapsed])
```

## `ToSeconds`

Converts a duration to its total number of seconds.

* **Syntax:** `ToSeconds(duration)`
* **Requires:** a Duration value.
* **Returns:** Numeric, including any fractional second.
* **Best for:** precise integrations and measurement exports.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
ToSeconds([Elapsed])
```

## `ToWeeks`

Converts a duration to its total number of seven-day weeks.

* **Syntax:** `ToWeeks(duration)`
* **Requires:** a Duration value.
* **Returns:** Numeric, including any fractional week.
* **Best for:** long service windows and age summaries.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
ToWeeks([Elapsed])
```

## `Weeks`

Creates a duration from a number of seven-day weeks.

* **Syntax:** `Weeks(number)`
* **Requires:** a Numeric value; fractions and negative values are allowed.
* **Returns:** Duration.
* **Best for:** long validity periods and elapsed-time rules.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Weeks(2)
```

<Info>
  `Days(1)` always means 24 elapsed hours. Use date functions such as `AdjustMonth` or `Workday` for calendar-aware movement.
</Info>
