Pass column to macro as variable

I am trying to pass a column into a macro for a calculation - specifically to take a date and return the # of days in that month. My code looks like this:

select {{ days_in_month(a.event_date) }}
from [table_name] a

when I try to build the model using ‘dbt run’, I get this error message: ‘a’ is undefined

I can’t find any examples in the docs where a column is passed into a macro, so maybe it’s not possible?

Thanks in advance for your help!

Hey. You need to wrap the text you pass the macro in quotation marks. In Jinja, it will otherwise think you are passing it the variable a.event_date.

This should compile (and run if macro is written correctly):

select {{ days_in_month('a.event_date') }}
from [table_name] a

Awesome, that did the trick. Thanks @dylanbaker!