> ## 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.

# Conversion functions

> Format values for clients and convert between supported formula types.

Use conversion functions at data boundaries: imported text, integration values, locale-specific numbers and dates, and calculated text shown to a client.

## `Format`

Formats a number, date, time, or timestamp as client-facing text.

* **Syntax:** `Format(value[, pattern[, unitOrCulture[, culture]]])`
* **Requires:** a numeric, date, time, or timestamp value. Number formatting accepts an optional pattern, unit, and culture. Date/time/timestamp formatting accepts a pattern and optional culture.
* **Returns:** Text.
* **Best for:** totals, units, percentages, dates, and times shown in forms or print output.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Format(12.5, "0.0 $", "kg", "en-US")
Format(#2026-08-31#, "dd MMM yyyy", "en-ZA")
```

Culture values use language tags such as `en-ZA`, `en-US`, or `de-DE`. A number pattern can also use standard forms such as `N2`, `F2`, `P1`, `C2`, or `E3`.

## `ToBoolean`

Converts a boolean, number, text value, or `null` into a boolean.

* **Syntax:** `ToBoolean(value)`
* **Requires:** a boolean, numeric, or text value. Non-zero numbers are true. Text is true only for `1`, `true`, or `yes`, ignoring case and surrounding spaces. `null` is false.
* **Returns:** Boolean.
* **Best for:** normalising imported flags before a condition.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
ToBoolean("YES")
```

## `ToDate`

Converts text to a date, or selects the local calendar date represented by a timestamp.

* **Syntax:** `ToDate(text[, culture])` or `ToDate(timestamp[, timeZone])`
* **Requires:** text or a timestamp. Text can include a culture such as `en-GB`; timestamps can include a timezone such as `Africa/Johannesburg` or `GMT+02:00`.
* **Returns:** Date.
* **Best for:** imported dates and timezone-aware integration timestamps.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
ToDate("31/08/2026", "en-GB")
```

## `ToNumber`

Converts text or a boolean into a number.

* **Syntax:** `ToNumber(value[, culture])`
* **Requires:** text, boolean, numeric, or `null`. The optional culture controls decimal and grouping separators. `true` becomes `1`, `false` and `null` become `0`.
* **Returns:** Numeric.
* **Best for:** CSV, API, or user-entered numbers that arrive as text.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
ToNumber("1.234,50", "de-DE")
```

## `ToText`

Prints a supported value as text using TeamDesk-compatible forms.

* **Syntax:** `ToText(value)`
* **Requires:** text, numeric, boolean, date, time, timestamp, duration, user, or `null`.
* **Returns:** Text, or `null` when the input is `null`.
* **Best for:** explicitly converting a value before joining or sending it.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Concat("Quantity: ", ToText([Quantity]))
```

Numbers are printed with six decimal places, booleans as `1` or `0`, and users by display name. Use `Format` when the presentation needs a specific pattern or culture.

## `ToTimeOfDay`

Converts text to a time of day, or selects the local time represented by a timestamp.

* **Syntax:** `ToTimeOfDay(text[, culture])` or `ToTimeOfDay(timestamp[, timeZone])`
* **Requires:** text or a timestamp, plus an optional culture/timezone appropriate to that input.
* **Returns:** Time.
* **Best for:** imported appointment times and timezone-aware response timestamps.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
ToTimeOfDay("11:30 PM", "en-US")
```

## `ToTimestamp`

Combines a date, optional time, and optional timezone into one timestamp.

* **Syntax:** `ToTimestamp(date[, time[, timeZone]])`
* **Requires:** a date; optional time defaults to midnight and optional timezone defaults to the current formula timezone.
* **Returns:** Timestamp.
* **Best for:** creating an exact moment from separate date and time fields.

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
ToTimestamp([Inspection Date], [Inspection Time], "Africa/Johannesburg")
```

<Tip>
  Convert at the edge of a formula, then keep the resulting value typed while you calculate.
</Tip>
