Skip to main content
Question

Pipelines/Jinja: How to check if datetime field is empty or not

  • May 2, 2023
  • 0 replies
  • 276 views

MattMakris
Forum|alt.badge.img+7

I'm running into an issue with an 'if' statement I'm using in a field in a Pipeline.

{% if a.$prev.client_live_date is not defined %}
  TBD
{% else %}
  {{a.$prev.client_live_date.strftime('%m/%d/%Y')}}
{% endif
%}

When the pipeline runs, it's throwing this error:
UndefinedError: 'None' has no attribute 'strftime'

Does anyone have a solution for this? Thank you.



------------------------------
Matt Makris
------------------------------
This topic has been closed for replies.

Forum|alt.badge.img+8

Hi Matt,

You can try replacing the is not defined with is None

Here, you're checking to see if date is null, or in Python the comparison would be None.

{% if a.$prev.client_live_date is None %}
  TBD
{% else %}
  {{a.$prev.client_live_date.strftime('%m/%d/%Y')}}
{% endif %}

Let me know if that works for you.



------------------------------
AR
------------------------------