# Variables

Variables can help configure time ranges, eliminate hardcoded values, or supply data for model configuration. In a ReOrc project, you can define variables as assets and use them across multiple models.

There are two scopes for variables in ReOrc:

* **Local variables** are defined in a model using Jinja syntax; they are scoped locally and only accessible within the model.&#x20;
* **Global variables** defined in **Library** > **Variables**, are project-level assets and accessible from any models in the project.&#x20;

When we refer to "variables" generally, we mean global variables.

Variables are defined with explicit types to remove the need for casting and prevent format errors. When building a model (whether in preview, console, or pipeline) that has variables, you can use pre-defined default values or overwrite them with custom inputs.

## Define a variable

To define a project variable, follow these steps:

1. In ReOrc, open your project and go to **Library** > **Variables**.
2. Click **+Add New**.
3. Provide the name, data type, description, and value for the variable.

   ReOrc supports creating project variables with explicit data types.

<figure><img src="https://786945529-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFTrGKWnjusKCQj11CkuL%2Fuploads%2F3kpaV7yCw0o3fI9Ycyd7%2FRecurve_create_variable_min_order_date.png?alt=media&#x26;token=cbbc8ef3-f36c-4a0a-b78c-8452340d45c7" alt=""><figcaption></figcaption></figure>

4. Click **Add**.

The new variable will be displayed in the **Variables** section of **Library**.

By default, a created variable is active and ready for use in models. You can deactivate the variable by toggling off the **Active** option.

## Use the variable

You can start referencing the defined variable in models with the `{{ var('variable_name') }}` expression.

For example, the following model uses the `min_order_dateime` defined in the project library.

```sql
select 
    id as order_id,
    customer as customer_id,
    ordered_at as order_date

from {{ source("jaffle_shop", "raw_orders") }}

where ordered_at >= {{ var('min_order_datetime') }}
```
