Forum Discussion

TomGause's avatar
TomGause
Qrew Trainee
10 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?

  • 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 %}

     

  • There may be a fancy way to do this with Jinja, but an expedient solution is to make a native QuickBase field called [Today plus 5 business days] and use it in the pipeline.

    WeekDayAdd([Today(), 5)

  • Mez's avatar
    Mez
    Qrew Cadet

    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 %}

     

    • TomGause's avatar
      TomGause
      Qrew Trainee

      Thank you, Mez!

      Am I interpreting this correctly? Does that formula say if today is either Monday, (1) Tuesday (2), Wednesday (3), Thursday (4), or Friday (5), add 7 calendar days. However, if today is Saturday (6), then add 6 calendar days. Otherwise, if today is Sunday (7), add 5 calendar days?