# How to convert list to int using jinja language

**URL:** <https://discourse.getdbt.com/t/how-to-convert-list-to-int-using-jinja-language/2244>\
**Category:** Archive\
**Created:** [March 11, 2021, 5:29am UTC](https://discourse.getdbt.com/t/how-to-convert-list-to-int-using-jinja-language/2244 "2021-03-11T05:29:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xzheng](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/xzheng/32/1694_2.png) [@xzheng](https://discourse.getdbt.com/u/xzheng)\
**Post date:** [March 11, 2021, 5:29am UTC](https://discourse.getdbt.com/t/how-to-convert-list-to-int-using-jinja-language/2244/1 "2021-03-11T05:29:37Z")

</div>

below is the scenario, planned to create a variable using run\_query method. but somehow, what i got is the list format. can anyone help me to convert list to int? tried to use results.columns.rows or results.columns. none of them works. anyone can help on this? really appreciated it.

{% macro SP\_TEST() %}

{% set get\_date\_parameter %}

SELECT TO\_VARCHAR(TO\_DATE(‘01/03/2021’),‘MM/DD/YYYY’),TO\_VARCHAR(TO\_DATE(‘03/03/2075’),‘MM/DD/YYYY’),

```
      datediff(month,'01/03/2021','03/03/2075'),   

      TO_VARCHAR(TO_DATE(CONCAT(DATE_PART(YEAR,'03/03/2075':: DATE),'-', DATE_PART(MONTH,'03/03/2075':: DATE ),'-01' )),'YYYY-MM-DD'),    

      TO_VARCHAR(LAST_DAY(TO_DATE('03/03/2075')),'YYYY-MM-DD')

```

{% endset %}

{% set results = run\_query(get\_date\_parameter) %}

{% if execute %}

{% set get\_total\_loop = results.columns[0].values() %}

{% else %}

{% set get\_total\_loop = 1 %}

{% endif %}

{% set counter = 1 %}

create or replace table semantic.test(id int)

{% for counter in range(1, get\_total\_loop) %}

{% if counter \< max\_counter %}

insert into semantic.test

select 1

{% endif %}

{%set counter = counter+1 %}

{% endfor %}

{% endmacro %}

Thanks,  
ALEX
