Skip to main content
Question

Jinja IF/Else with some math

  • December 19, 2023
  • 0 replies
  • 341 views

Forum|alt.badge.img+6

I have a pipeline snippet below that functions as require, however, I have two issue that I cannot get past.

The duration code below stems from an actual duration field between two dates plus days(1) to capture first and last day.

The snippet is part of a larger Outlook channel HTML email

/// SNIPPET ///

{# Duration between 2 dates #}
{% if a.duration>0 %}
Duration: {{a.duration}} Day(s)
{% else %}
{% endif %}

/// RESULTS ///

Duration: 86400000 Day(s)

/// Issue #1 ///

No matter what I try, I cannot deduce the milliseconds to actual days. Dividing my duration by 86400000 should give me 1 Day, I simply cannot get the jinja code correctly update to achieve this result.

/// Issue #2 ///

The snippet provides a line feed or break regardless if the statement is true or false.



------------------------------
Thank you so much,

v/r,
Chuck
------------------------------
This topic has been closed for replies.

Forum|alt.badge.img+9
  • Registered
  • December 19, 2023

How are you trying to convert it? Something like: Duration: {{a.duration / 86400000}} Day(s) works when I test it. You can try {{a.duration|int / 86400000}} to see if that works as well. Worst case you could always make a formula-text field in your record that builds that Duration: n Days(s) string and then just populate the email with that value as well instead of converting in the PIpeline. 



------------------------------
Chayce Duncan
------------------------------