Formatting Tokens to Display Date and Time

  • Browser
  • iPad

Content creators can edit Approved Email tokens that reference dates and times to specify their own datetime format. This expands flexibility when creating content that may reference dates and times in multiple ways.

For example, Alice Adams is a content creator who creates an Approved Email Template to serve as an invitation to events. She wants the invitation to display the date and day of the week that the event takes place on. She adds the {{EM_Event_vod__c.Start_Time_vod__c(eeee MMMM dd, yyyy)}} token to the template, which specifies the appropriate date and time format. Later, when Sarah Jones uses this template to serve as invitations to her upcoming event, she previews the invitation and sees the Start_Time_vod field render in the format Alice specified.

Specifying the Format of a Date or Time Token

The following Approved Email tokens are supported in Approved Email Templates, Fragments, and Template Fragments:

  • {{ObjectAPIName.FieldAPIName}}
  • {{ObjectAPIName.RelationshipName.FieldAPIName}}
  • {{Object1APIName.FieldAPIName;;Object2APNIName.FieldAPIName}}

    The field to formatting must be listed last in the list of tokens.

  • {{parentCallDatetime}}
  • {{insertCallSample}}
  • {{insertMedicalInquiry}}
  • {{insertOrderLine}}
  • {{customText[##mergeToken1##|##ObjectAPIName.FieldAPIName##]}}

Formatting tokens to display date and time are not supported in Event Materials print invitation templates.

To specify the format for a rendered date or time:

  1. Add the (FORMAT) placeholder parameter to the appropriate token. For example, {{parentCallDatetime}} becomes {{parentCallDatetime(FORMAT)}}.
  2. Replace the FORMAT placeholder with the appropriate format. Supported format elements include:

    Element

    Supported Field Types

    Format

    Description

    Example Token

    Example Output

    Year

    DateDate/Time

    yyyy

    Full year

    {{parentCallDatetime(MMMM d, yyyy)}}

    April 1, 2022

    Month

    DateDate/Time

    M

    Numeric month

    {{parentCallDatetime(M d, yyyy)}}

    4 1, 2022

    MM

    Numeric month with padded 0 if the value is less than 10

    {{parentCallDatetime(MM d, yyyy)}}

    04 1, 2022

    MMM

    Translated shortened month name

    {{parentCallDatetime(MMM d, yyyy)}}

    Apr 1, 2022

    MMMM

    Translated month name

    {{parentCallDatetime(MMMM d, yyyy)}}

    April 1, 2022

    Day

    DateDate/Time

    d

    Numeric day

    {{parentCallDatetime(MMMM d, yyyy)}}

    April 1, 2022

    dd

    Numeric day with padded 0 if the value is less than 10

    {{parentCallDatetime(MMMM dd, yyyy)}}

    April 01, 2022

    Weekday

    DateDate/Time

    eee

    Translated shortened day of the week

    {{parentCallDatetime(eee, MM/dd)}}

    Fri, 04/01

    eeee

    Translated day of the week

    {{parentCallDatetime(eeee, MM/dd)}}

    Friday, 04/01

    Hour

    Date/TimeTime

    h

    Hour (12-hour time)

    {{parentCallDatetime(eee, h:mm a)}}

    Fri, 2:00 pm

    hh

    Hour (12-hour time) with padded 0 if the value is less than 10

    {{parentCallDatetime(eee, hh:mm a)}}

    Fri, 02:00 pm

    H

    Hour (24-hour time)

    {{parentCallDatetime(eee, H:mm)}}

    Fri, 14:00

    HH

    Hour (24-hour time) with padded 0 if the value is less than 10

    {{parentCallDatetime(eee, HH:mm)}}

    Thur 08:00

    Minute

    Date/TimeTime

    mm

    Minute

    {{parentCallDatetime(eee, h:mm a)}}

    Fri, 2:00 pm

    AM/PM

    Date/TimeTime

    a

    Use with 12-hour time elements to designate AM vs PM

    {{parentCallDatetime(eee, h:mm a)}}

    Fri, 2:00 pm

    Additionally, content creators can add spaces, non-breaking spaces (&nbsp), or any of the following single character symbols to separate format elements:

    • Grave `
    • Up caret ^
    • Underscore _
    • Dash -
    • Colon :
    • Question mark ?
    • Period .
    • Plus +
    • Equals =
    • At symbol @
    • Asterisk *
    • Forward-slash /
    • Back-slash \
    • Ampersand &
    • Tilde ~
    • Dollar sign $
    • Comma ,
    • Semi-colon ;

    For example, {{parentCallDatetime(eeee, MMMM d yyyy @ h:mm a)}} renders as:

    Friday, April 1 2022 @ 12:30 pm

Brackets [ ], Curly brackets {}, and the # character are not supported for separating format elements.

Considerations

  • Content creators should thoroughly test all content that formats dates and times via this feature
  • Months and days of the week automatically translate based on the sender’s language
  • Formatting is not supported with the {{customContent}} token used to query Approved Email data
  • Tokens without any datetime formatting will render in Salesforce’s default MM/dd/yyyy for dates and yyyy-MM-ddThh:mm:ss for datetimes