# How to use variables in definition.yml

**URL:** <https://discourse.getdbt.com/t/how-to-use-variables-in-definition-yml/3567>\
**Category:** Archive\
**Created:** [December 31, 2021, 7:16am UTC](https://discourse.getdbt.com/t/how-to-use-variables-in-definition-yml/3567 "2021-12-31T07:16:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![surabhi\_pandey](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/surabhi_pandey/32/962_2.png) [@surabhi\_pandey](https://discourse.getdbt.com/u/surabhi_pandey)\
**Post date:** [December 31, 2021, 7:16am UTC](https://discourse.getdbt.com/t/how-to-use-variables-in-definition-yml/3567/1 "2021-12-31T07:16:00Z")

</div>

Hello All,

I want to use variables defined in the dbt\_project.yml in definition.yml for testing the models.  
But so far these variables are not being recognized when running the test cases using _dbt test -m \<model\_name\>_  
Is there are way to access variables in definition.yml ?

My code looks like this

**dbt\_project.yml**

```auto
name: 'first_dbt_project'
version: '1.0.0'

# This setting configures which "profile" dbt uses for this project.
profile: default
config-version: 2
source-paths: ["models"]
analysis-paths: ["analysis"]
test-paths: ["tests"]
data-paths: ["data"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]

clean-targets:   
    - "target"
    - "dbt_modules"

vars:
  runDate: 20210131
  intakeDate: 202106

```

_ **definition.yml** _

```auto
version: 2

models:
  - name: first_model
    tests:
      - dbt_utils.expression_is_true:
          expression: "len(machine_id) between 8 and 9 "
          where: "rundate > {{ var('rundate')}}"

```
