# Data types and operators

Data types define what a script value is. Operators define what you do with that value.

{% hint style="info" %}
Do not confuse **data fields** with **data types**. A data field is something you add in **Builder mode**, such as **Text**, **Number**, or **Date and time**. A data type is the value your script reads or returns, such as text, number, date, datetime, record, or array.
{% endhint %}

For deeper explanations and examples, open [Operators](/ninox-scripting/automate-your-workflows/explore-core-scripting-elements/operators.md) and [Explore core scripting elements](/ninox-scripting/automate-your-workflows/explore-core-scripting-elements.md).

Jump to: [Data types](#data-types) · [Operators](#operators) · [Conversions](#conversions) · [Common gotchas](#common-gotchas)

## **Data types**

Data types describe what an expression returns or a variable stores. Knowing the type helps you choose the right operator and conversion.

### **Map common field types to scripting values**

These mappings help you keep Builder terminology and scripting terminology separate:

* **Text** and **Multi-line text** fields return **Text** values.
* **Number** fields return **Number** values.
* **Yes/no** fields return **Yes/No** values.
* **Date** fields return **Date** values.
* **Date and time** fields return **Datetime** values.
* **Time** fields return **Time** values.
* **Appointment** fields return **Appointment** values.
* **Relationship** fields return **Record** references or lists of records.
* **File**, **Location**, and **User** fields return specialized values of the same kind.
* **Views**, **Charts**, **Controls**, **Layouts**, and **Dynamic** elements are builder components, not scripting data types.

### **Start with the core types**

Most scripts use these types first:

* **Text** stores labels, messages, and other words, for example `"Hello"` or `---Hello {'First name'}!---`.
* **Number** stores values you calculate with, for example `125` or `19.95`.
* **Yes/No** stores `true` or `false`. Comparison operators return this type.

### **Use date and time types for scheduling**

Use different time-related types depending on what you need to keep:

* **Date** stores a calendar date without a time, for example `today()` or `date(2026, 3, 23)`.
* **Time** stores a time of day, for example `time(14, 30)`.
* **Datetime** stores a local date and time together, for example `datetime(2026, 3, 23, 14, 30)`.
* **Timestamp** stores a time-based value in timestamp form, for example `timestamp(now())`.
* **Appointment** stores a start and end together, for example `appointment(now(), timeinterval(1, "hours"))`.
* **Duration** stores a time span, for example `duration(End, Start)`.

### **Use structured types to work with records and data**

These types help when you move beyond simple values:

* **Record** stores a reference to one record, for example `first(select Customers)`. Use `.` to access its fields.
* **Array** stores a list of values, for example `[1, 2, 3]` or `select Invoices`.
* **JSON** stores structured key-value data, for example `parseJSON("{\"status\":\"Open\"}")`.
* **File** stores a file reference, for example `file(Attachment)`.
* **Location** stores a place with coordinates, for example `location("Office", 52.52, 13.405)`.
* **User** stores a workspace user, for example `user()`.

## **Operators**

Operators let you assign, calculate, compare, and access values. Choose them by the job you want to do.

### **Assign and access values**

Use these operators to store values and read data:

* `:=` assigns a value to a variable or field, for example `let total := Price * Quantity`.
* `.` accesses a field on a record or a value in an object, for example `customer.Name`.
* `;` ends a statement, for example `let total := 100;`.

### **Calculate with arithmetic operators**

Use arithmetic operators for totals, quantities, percentages, and similar calculations:

* `+` adds numbers and can also join text, for example `1 + 2` or `"Hello " + 'First name'`.
* `-` subtracts one number from another, for example `Net - Discount`.
* `*` multiplies numeric values, for example `Price * Quantity`.
* `/` divides one number by another, for example `Total / 4`.
* `%` returns the remainder after division, for example `13 % 5`.
* `()` changes the order of calculation, for example `(1 + 2) * 3`.

### **Compare values in conditions**

Use comparison operators when a script needs to decide what happens next:

* `=` checks whether two values are equal, for example `Status = "Open"`.
* `!=` checks whether two values are different, for example `Status != "Closed"`.
* `>` and `>=` check whether the left value is greater.
* `<` and `<=` check whether the left value is smaller.
* `like` checks whether one text appears inside another text, for example `"Hello" like "ell"`.

### **Combine conditions**

Use logical operators when one check is not enough:

* `and` requires both conditions to be true, for example `Status = "Open" and Total > 100`.
* `or` requires at least one condition to be true, for example `Status = "Open" or Status = "Pending"`.

### **Write text and field names correctly**

Use the right syntax for text and names:

* `""` marks a text value, for example `"Open"`.
* `---` marks a longer text value, for example `---Hello {'First name'}!---`.
* `''` wraps field or table names with spaces or special characters, for example `'First name'`.

## **Conversions**

Use conversions when a value has the right content but the wrong type.

Use these functions most often:

* `text(any)` converts a value to readable text. Use it when you build messages such as `"Order " + text(Number)`.
* `number(any)` converts a value to a number. This helps when imported values arrive as text.
* `date(any)` converts a value to a date and removes the time part when needed.
* `datetime(...)` creates or converts a local date and time value.
* `timestamp(any)` converts a time-based value to a timestamp.
* `parseJSON(string)` converts JSON text into a JSON object.
* `formatJSON(JSON)` converts a JSON object into JSON text.

## **Common pitfalls**

These are the mistakes that come up most often:

* Use `:=` to assign values. Use `=` to compare values. It is easy to confuse them when you switch from writing logic to checking a condition.
* Use single quotes for field or table names like `'First name'`. Use double quotes for text like `"Hello"`. Mixing them changes how Ninox reads the expression.
* `+` can add numbers or join text. If one part is not already text, convert it first with `text()`, for example `"Order " + text(Number)`.
* `like` checks whether one text appears inside another text. Use `=` when values must match exactly.
* The dot operator needs a record or object value on the left side, for example `let customer := first(select Customers); customer.Name`. If the left side is not a record, Ninox cannot read the field.


---

# Agent Instructions: 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:

```
GET https://docs.ninox.com/ninox-scripting/functions-and-script-library/data-types-and-operators.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
