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

# Operators

> Use all 15 arithmetic, text, comparison, and logical operators.

Operators combine or compare values without a function call. Parentheses make complex expressions easier to read and remove ambiguity.

## Arithmetic and text

| Operator | Requires                                                                                                           | Returns                                                        | Example                     |
| -------- | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------- | --------------------------- |
| `+`      | Two Numerics; two Durations; or a Date, Time, or Timestamp paired with a Duration in either order                  | Numeric or Duration sum, or the shifted date/time value        | `[Quantity] + 1`            |
| `-`      | Two Numerics; two Durations; a Date, Time, or Timestamp minus a Duration; or two values of the same date/time type | Numeric or Duration difference, or the shifted date/time value | `[End Date] - [Start Date]` |
| `*`      | Two Numerics, or one Duration and one Numeric in either order                                                      | Numeric product or scaled Duration                             | `[Elapsed] * 1.5`           |
| `/`      | Two Numerics, a Duration divided by a Numeric, or one Duration divided by another; divisor must not be zero        | Numeric quotient, scaled Duration, or Numeric duration ratio   | `[Total] / [Count]`         |
| `^`      | Numeric base and exponent                                                                                          | Base raised to the exponent                                    | `2 ^ 8`                     |
| `&`      | Two printable, non-null values                                                                                     | Text joined end to end                                         | `"REF-" & [Record Number]`  |

Unary `+` leaves a Numeric or Duration unchanged. Unary `-` negates it.

<Note>
  When an arithmetic operation expects a Numeric, `null` is treated as zero. Text is never converted to a number automatically; use `ToNumber` when conversion is intentional.
</Note>

## Comparisons

| Operator | Meaning               | Example                   |
| -------- | --------------------- | ------------------------- |
| `=`      | Equal                 | `[Status] = "Ready"`      |
| `<>`     | Not equal             | `[Status] <> "Cancelled"` |
| `>`      | Greater than          | `[Temperature] > 8`       |
| `>=`     | Greater than or equal | `[Score] >= 80`           |
| `<`      | Less than             | `[Quantity] < 1`          |
| `<=`     | Less than or equal    | `[Due Date] <= Today()`   |

Both operands must be comparable values of the same type. A comparison involving `null` returns `false`, including `null = null` and `null <> null`.

## Logical operators

| Operator | Requires     | Returns                        | Example                   |
| -------- | ------------ | ------------------------------ | ------------------------- |
| `and`    | Two booleans | `true` only when both are true | `[Active] and [Approved]` |
| `or`     | Two booleans | `true` when either is true     | `[Urgent] or [Overdue]`   |
| `not`    | One boolean  | The opposite boolean           | `not [Archived]`          |

`and` and `or` short-circuit: Dsync skips the right-hand side when the left side already determines the result.

## Precedence

From highest to lowest:

1. Unary `not`, `+`, `-`
2. Power `^`
3. Multiplication and division `*`, `/`
4. Addition, subtraction, and concatenation `+`, `-`, `&`
5. Comparisons `=`, `<>`, `>`, `>=`, `<`, `<=`
6. `and`
7. `or`

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
([Quantity] * [Unit Price] >= 1000) and not [On Hold]
```

<Tip>
  Use parentheses around each business condition, even when precedence would produce the same result.
</Tip>
