Reputation: 411
I want to use the execution time in Airflow and add one day to it:
'{{(execution_date + timedelta(days=1)).strftime("%Y-%m-%d")}}'
When I execute this I get
jinja2.exceptions.UndefinedError: 'timedelta' is undefined
How can I get the execution time plus one day?
Upvotes: 3
Views: 4284
Reputation: 666
'{{(execution_date + macros.timedelta(days=1)).strftime("%Y-%m-%d")}}'
Use macros to pass dynamic information into task instances at runtime.
Upvotes: 1
Reputation: 411
I found the answer here: https://diogoalexandrefranco.github.io/about-airflow-date-macros-ds-and-execution-date/
You can use:
'{{(execution_date + macros.timedelta(days=1)).strftime("%Y-%m-%d")}}'
The macros object exposes common python functions and libraries like macros.datetime and macros.timedelta
Upvotes: 7