I have two dates in a template that I need to compare in an if statement.
Date1 is from the created field of a data element {{ endjob.created|date:"Y-m-d" }} that is displayed as 2016-09-12
Date2 if from an array {{ pay_period.periods.0.0 }} that is displayed as 2016-09-04
Therefore I am trying to ask to display information only if Date1 >= Date2 but I do not get any data.
Can you help me with how to clash dates in templates in Django
This is my code:
<tbody>
{% for endjob in endjob %}
{% if endjob.created|date:"Y-m-d" >= pay_period.periods.0.0 %}
<tr>
<td><a href="{{ endjob.get_absolute_url }}" title="Goto Form">{{ endjob.event.name }}</a><br /></td>
<td>{{ endjob.event.job_no}} <br /></td>
<td>{{ endjob.event.job_type}} <br /></td>
<td>{{ endjob.code }} <br /></td>
<td>{{ endjob.crewid }}<br /></td>
<td>{{ endjob.workers }}<br /></td>
<td>{{ endjob.created|user_tz:user|date:"M j, Y" }}<br /></td>
</tr>
{% endif %}
{% endfor %}