Forum Discussion

TomGause's avatar
TomGause
Qrew Trainee
11 days ago
Solved

Jinja Question: Adding business days to today

In my Pipeline, I have a “start date” and “end date.” The start date is {{ today.now }}. For the end date, I want the pipeline to add 5 business days to the start date. Is there a way to do that?
  • Mez's avatar
    11 days ago

    Here is how you can achieve this in jinja. 

    Using isoweekday  Monday is 1 and Sunday is 7. (assumes exclusive)

    {% if (time.now.date()).isoweekday() <= 5 %}
    {{ time.now.date() + time.delta(days=7) }}
    {% elif (time.now.date()).isoweekday() == 6 %}
    {{ time.now.date() + time.delta(days=6) }}
    {% else %}
    {{ time.now.date() + time.delta(days=5) }}
    {% endif %}