# error when using variable of marcos

**URL:** <https://discourse.getdbt.com/t/error-when-using-variable-of-marcos/13286>\
**Category:** Help\
**Tags:** jinja, variables, macros\
**Created:** [May 10, 2024, 1:43pm UTC](https://discourse.getdbt.com/t/error-when-using-variable-of-marcos/13286 "2024-05-10T13:43:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KANA\_MADAO](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@KANA\_MADAO](https://discourse.getdbt.com/u/KANA_MADAO)\
**Post date:** [May 10, 2024, 1:43pm UTC](https://discourse.getdbt.com/t/error-when-using-variable-of-marcos/13286/1 "2024-05-10T13:43:16Z")

</div>

I have a problem, there is a macro in which I calculate the date and want to pass it to the model

```auto
{% macro get_report_date() %}
{% if execute %}
{% set p_date = run_query("select max(report_date) as report_date from dwh_dq.dwh_schedule ds where status=1" ).columns[0][0] %}
{% else %}
{% set p_date = '2024-05-01' %} 
{% endif %}
{%do return(p_date)%}
{% endmacro %}

```

in the model I declare a variable and assign the result of the macro to it in order to use this variable in pre\_hook

```auto
{% set p_date_v2 = get_report_date() %}
{{
    config(
      pre_hook=[
       "{{ insert_dwh_log(schema_name='dwh_dds',table_name='organizations_type',source_name='BOS',report_date=p_date_v2,pre_hook=True) }}"
          ]
      
    )
}} 

```

and I got an error  
**invalid input syntax for type date: “”**  
**LINE 4: …organizations\_type’ and source\_name=‘BOS’ and report\_date=‘’**  
like it doesnt see the date  
but if I call marcos in pre\_hook it’s work correctly

```auto
"{{ insert_dwh_log(schema_name='dwh_dds',table_name='organizations_type',source_name='BOS',report_date=get_report_date(),pre_hook=True) }}"

```

it see the date 2025-05-02.

Someone please explain me what I do wrong???

---

<div class="post-metadata">

**Author:** ![KANA\_MADAO](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@KANA\_MADAO](https://discourse.getdbt.com/u/KANA_MADAO)\
**Post date:** [May 13, 2024, 5:13am UTC](https://discourse.getdbt.com/t/error-when-using-variable-of-marcos/13286/2 "2024-05-13T05:13:40Z")

</div>

In macros insert\_dwh\_log it doesnt see the value of variable, I dont know why

---

<div class="post-metadata">

**Author:** ![KANA\_MADAO](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@KANA\_MADAO](https://discourse.getdbt.com/u/KANA_MADAO)\
**Post date:** [May 13, 2024, 6:08am UTC](https://discourse.getdbt.com/t/error-when-using-variable-of-marcos/13286/4 "2024-05-13T06:08:59Z")

</div>

solution

> <https://stackoverflow.com/questions/73301134/how-to-pass-variable-while-calling-macros-in-post-hook>
