Summary
For company events you have start and end dates. Calculate the duration from the two fields (Id: start; Id: end) in a fieldset (Id: duration) and show the values in days, or only the start date.
{% if data.duration.end %}
{% assign end = data.duration.end | date: '%s' %}
{% assign start = data.duration.start | date: '%s' %}
{% assign durationSeconds = end | minus: start %}
{% assign durationDays = durationSeconds | divided_by: 3600 | divided_by: 24 %}
This event lasted {{ durationDays }} days.
{% else %} This event started data.duration.start | local_date: "%d.%m.%Y %H:%M:%S".
{% endif %}
JSON
Setup in Picturepark
Field Value Access
data.corporateInformation.duration | fieldset_list: "Duration"
data.corporateInformation.duration | fieldset_name: "Duration"
Use Case
In the Fieldset schema, the Display Pattern could calculate the duration in days, when an end date is provided or otherwise just show the start date.
{% if data.duration.end %}
{% assign end = data.duration.end | date: '%s' %}
{% assign start = data.duration.start | date: '%s' %}
{% assign durationSeconds = end | minus: start %}
{% assign durationDays = durationSeconds | divided_by: 3600 | divided_by: 24 %}
This event lasted {{ durationDays }} days.
{% else %} This event started data.duration.start | local_date: "%d.%m.%Y %H:%M:%S".
{% endif %}
JSON