Format participant date fields in templates
A visible participant field of type Date can be output in various formats in email and PDF templates. You can thus use the same stored value as a complete date or just a year, for example.
Check the date field and placeholder names
- Open the participant data fields and check that the field is visible and configured as a date. A text field that merely looks like a date is insufficient.
- Open the email or PDF template and insert the exact participant placeholder using the menu. Custom names are derived from the field name; special characters may be omitted.
- Add the desired format in square brackets before the final double hashes.
- Check a person with a valid date and one with an empty field in the actual output.
Use common formats
| Notation | Example output |
|---|---|
##UserGeburtsdatum## | Stored or usual representation of the field. |
##UserGeburtsdatum[d.m.Y]## | 17.05.1990 |
##UserGeburtsdatum[Y-m-d]## | 1990-05-17 |
##UserGeburtsdatum[d/m/Y]## | 17/05/1990 |
##UserGeburtsdatum[Y]## | 1990 |
##UserGeburtsdatum[Y-m]## | 1990-05 |
In these examples, your field must actually have the placeholder name UserGeburtsdatum. d stands for the day with a leading zero, m for the month, and Y for the four-digit year. Formats containing weekday or month names may produce English names; numeric formats are often clearer for multilingual templates.
Account for empty or invalid date values
Missing or invalid date values produce empty output in the formatted variant. This also applies to incomplete values such as year and month only, to 0000-00-00 and to invalid calendar dates. Today’s date is not substituted.
{IF?UserGeburtsdatum != }<p>Date of birth: ##UserGeburtsdatum[d.m.Y]##</p>{ENDIF}The condition checks the existing source value, rather than its substantive validity. Correct invalid stored data in the participant profile. A date containing a time or time zone is output in the account time zone and may result in a different calendar day. Check imported values particularly carefully.
If output remains empty
- Is the field visible and actually of type Date?
- Was the placeholder name copied exactly from the editor?
- Does the specific person have a valid complete date value?
- Does the process supply a participant profile, rather than, for example, a freely entered recipient address without a profile?
- Is the format between the brackets non-empty, and are both double hashes present?
Check a formatted date specifically
Use a fixed, known complete date for comparison. Format characters must be written exactly: Y produces the four-digit year, m the month and d the day with a leading zero. The format changes the appearance in this template; it does not change the stored participant value.
An IF condition uses the normal variable name without a format suffix. Therefore do not compare a formatted date string using a numeric size operator. If you want to see ‘Date of birth:’ only for valid data, first clean up invalid source values in the profile.