> For the complete documentation index, see [llms.txt](https://docs.rainbird.ai/rainbird/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rainbird.ai/rainbird/knowledge-modelling/modelling-features/rblang-reference/functions-reference.md).

# Functions reference

Use these functions inside `expression` conditions.

For UI-focused examples, see [Expressions List](/rainbird/knowledge-modelling/modelling-features/relationships/rules/expressions-list.md).

### Comparison

Use comparison functions to return `true` or `false`.

* `is equal to`
* `is not equal to`
* `is greater than`
* `is greater than or equal to`
* `is less than`
* `is less than or equal to`
* `isWithinRange(val, min, max)`

Examples:

```xml
<condition expression="%AGE is greater than 30"/>
<condition expression="isWithinRange(%AGE, 18, 35)"/>
```

### String

Use string functions for matching and text construction.

* `includes(str, substr)`
* `startsWith(str, prefix)`
* `endsWith(str, suffix)`
* `regexCount(str, pattern)`
* `+` for concatenation

For `regexCount()`, the pattern must be a JavaScript-flavoured (ECMAScript) regex in `/pattern/flags` format.

Example: `'/cat/gi'`

Examples:

```xml
<condition expression="includes(%TEXT, 'cat')"/>
<condition expression="'Status: ' + %NAME" value="%O"/>
```

### Mathematical

Use math functions with number values.

* `+`, `-`, `*`, `/`
* `round(num, decimals)`
* `ceil(num)`
* `floor(num)`
* `abs(num)`
* `min(n1, n2, ...)`
* `max(n1, n2, ...)`
* `mod(num, divisor)`
* `pow(base, exp)`
* `sqrt(num)`

Example:

```xml
<condition expression="round((%SCORE_1 + %SCORE_2) / 2, 2)" value="%O"/>
```

### Date

Use date functions with `date` concepts and date literals.

* `today()`
* `now()`
* `dayOfWeek(date)`
* `dayOfMonth(date)`
* `dayOfYear(date)`
* `monthOfYear(date)`
* `year(date)`
* `addDays(date, n)`
* `subtractDays(date, n)`
* `addWeeks(date, n)`
* `addMonths(date, n)`
* `addYears(date, n)`
* `daysBetween(d1, d2)`
* `weeksBetween(d1, d2)`
* `monthsBetween(d1, d2)`
* `yearsBetween(d1, d2)`
* `isBeforeDate(d1, d2)`
* `isSameDate(d1, d2)`
* `isAfterDate(d1, d2)`

Use date strings in `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM:SS` format.

### List

List functions work over relationship instances. They are most useful with plural relationships.

Use `*` for `all` or variables and literals to filter the subject or object values used by the function.

* `countRelationshipInstances(subject, relationship, object)`
* `sumObjects(subject, relationship, object)`
* `minObjects(subject, relationship, object)`
* `maxObjects(subject, relationship, object)`
* `joinObjects(subject, relationship, object)`
* `isSubset(subject1, relationship1, object1, subject2, relationship2, object2)`

Examples:

```xml
<condition expression="countRelationshipInstances(%S, 'purchased product', *)" value="%COUNT"/>
<condition expression="sumObjects(%S, 'has score', *)" value="%SUM"/>
```

### Logical operators

Use `and` and `or` to combine tests.

```xml
<condition expression="(%AGE >= 25) and (%AGE <= 40)"/>
<condition expression="(%AGE < 25) or (%AGE > 60)"/>
```

Use parentheses to control evaluation order.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.rainbird.ai/rainbird/knowledge-modelling/modelling-features/rblang-reference/functions-reference.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
