# How to pass Date Variable as string while running the DBT Jobs

**URL:** <https://discourse.getdbt.com/t/how-to-pass-date-variable-as-string-while-running-the-dbt-jobs/9435>\
**Category:** Help\
**Tags:** jinja, snowflake\
**Created:** [August 7, 2023, 8:01am UTC](https://discourse.getdbt.com/t/how-to-pass-date-variable-as-string-while-running-the-dbt-jobs/9435 "2023-08-07T08:01:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sargunan](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@sargunan](https://discourse.getdbt.com/u/sargunan)\
**Post date:** [August 7, 2023, 8:01am UTC](https://discourse.getdbt.com/t/how-to-pass-date-variable-as-string-while-running-the-dbt-jobs/9435/1 "2023-08-07T08:01:50Z")

</div>

Hey Everyone.

I have dbt Jobs which is having an Variable (String) which has the Date. Everytime we run the job either we modify the date or update in project YML File. Since we have completed the history load now we would need to automate this by passing the Curernt date -1 and covert into string. Example we expect “2023-08-01”.

Example  
dbt build --vars ‘{key: value, thru\_date: 2023-08-04}’ --select ++

This thru\_date Variables we have been using in Modes to filter the data set in source. Now how we convert the Hardcode values to Dymically with sysdate-1 ?

---

<div class="post-metadata">

**Author:** ![lennart](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@lennart](https://discourse.getdbt.com/u/lennart)\
**Post date:** [August 23, 2023, 1:42pm UTC](https://discourse.getdbt.com/t/how-to-pass-date-variable-as-string-while-running-the-dbt-jobs/9435/2 "2023-08-23T13:42:38Z")

</div>

is it possible for you to use a macro instead of a variable? e.g. using this:

> [@Accessing a dynamically-set variable in multiple models](https://discourse.getdbt.com/t/accessing-a-dynamically-set-variable-in-multiple-models/1134):
>
> I know I can execute a query in a model and assign the result to a variable in this way: {% if execute %} {% set last\_audit\_id = run\_query("SELECT LAST\_AUDIT\_ID FROM CFG.PAR\_SCDM\_AUDIT WHERE FLOW = ‘ORDER\_MOVEMENT’ ").columns[0][0] %} {% endif %} but this variable is local to this model. Is there a way to do the same thing in dbt\_project.yml and thus feed a project-wide variable? Thanks Daniele
