# date\_spine macro with sql statements throws syntax errors

**URL:** <https://discourse.getdbt.com/t/date-spine-macro-with-sql-statements-throws-syntax-errors/9717>\
**Category:** Help\
**Tags:** snowflake\
**Created:** [August 26, 2023, 11:31am UTC](https://discourse.getdbt.com/t/date-spine-macro-with-sql-statements-throws-syntax-errors/9717 "2023-08-26T11:31:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Parshu](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@Parshu](https://discourse.getdbt.com/u/Parshu)\
**Post date:** [August 26, 2023, 11:31am UTC](https://discourse.getdbt.com/t/date-spine-macro-with-sql-statements-throws-syntax-errors/9717/1 "2023-08-26T11:31:56Z")

</div>

## The problem I’m having

```
  Using sql statements within the date_spine macro is throwing syntax errors.  

```

## The context of why I’m trying to do this

dbt version: 1.4.6  
dbt-labs/dbt\_utils version: 1.0.0  
database-engine: Snowflake

## What I’ve already tried:

```
  I had this working with one sql statement and one date, but now I keep getting different errors. I also tried adding a ::date to cast the columns and get the same errors.

```

## Some example code or error messages

```cal_days
    {{ dbt_utils.date_spine(
        datepart="day",
        start_date="(select date_trunc('MONTH', min(month_end)) from "~ref('stage_accounting_month_ends')~")",
        end_date="(select max(month_end)) from "~ref('stage_accounting_month_ends')~")"
        )
    }}
),
11:22:50 Database Error in model calendar (models/base/reimbursement/calendar.sql)
11:22:50 001003 (42000): SQL compilation error:
11:22:50 syntax error line 4 at position 32 unexpected 'from'.
11:22:50 syntax error line 4 at position 84 unexpected ')'.
11:22:50  
11:22:50 Done. PASS=0 WARN=0 ERROR=1 SKIP=0 TOTAL=1

```

---

<div class="post-metadata">

**Author:** ![Parshu](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@Parshu](https://discourse.getdbt.com/u/Parshu)\
**Post date:** [August 29, 2023, 4:11pm UTC](https://discourse.getdbt.com/t/date-spine-macro-with-sql-statements-throws-syntax-errors/9717/2 "2023-08-29T16:11:55Z")

</div>

nevermind - figured it out - silly mistake
