I store an end date(last_day_for_payment) for Event payment in SalesForce. I send reminder 3 month before last_day_for_payment that date and ask user to pay before 2 month of last_day_for_payment to get discount. Is there a way to use some kind of formula to add/substract date in visual force email template. eg {!relatedTo.last_day_for_payment} - 2 months

Right now I am using formula field named last_day_for_discount to store the date 2 month ahead of last_day_for_payment

Now the main question:

I can use format date in email template body with OutputText tab like below,

<apex:outputText value='{0, date, MMMM d}'><apex:param value='{!relatedTo..last_day_for_discount}' /></apex:outputText>

I want to have email subject line like this: IMPORTANT: Please pay your fee by 5 May

I have following code which create subject line,

<messaging:emailTemplate subject="IMPORTANT: Please pay your fee by {!relatedTo.last_day_for_discount}" recipientType="Contact" relatedToType="Events">

This display date as it is stored in SF: "07/01/2016" Can I format it, in subject line, like to get only '7 Jan' somehow?! Outputtext does not work in subject.

Any help highly appreciated.

1 Answer 1


If you are open to using more formulas, you could do something like the following. You may wish to add a local intermediary as the time zone will be GMT. There are many other posts out there about how to deal with that issue so I will just focus on OP.

    1, "Jan", 2, "Feb", 3, "Etc"
) & DAY(MyDateTime__c)

Unfortunately, you may still run into locale issues with this approach even after working around the time zone if you are in an international instance. You could use labels instead of the strings above if you need any translation.

  • Perfect! Thank you very much Adrian for the right guidance. I wish Salesforce has easy way of doing such things inside templates.
    – Neerav
    Commented Jan 8, 2016 at 9:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .