Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I need to format a date field in Visual Force email template so that it is of the form:

December 5, 2012

I check date format guidelines in force documentation and find this: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_outputText.htm

I don't think this does not give me the full range of options available. Anyone got a link which does?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I think here you will be needed an apex method, something like this:

public List<String> monthList = new List<String>{'January',
                                                 'February',
                                                 'March',
                                                 'April',
                                                 'May',
                                                 'June',
                                                 'July',
                                                 'August',
                                                 'September',
                                                 'October',
                                                 'November',
                                                 'December'};

public String getDateFormatted(Date myDate)
{
    return monthList.get(myDate.month() - 1) + ' ' + myDate.day() + ', ' + myDate.year();
}

UPDATE: for use at the visualforce page you can use following code:

<apex:outputText value="{0,date, MMMM ,d  yyyy}">
    <apex:param value="{!NOW()}" />
</apex:outputText>

See the Java documentation for all the pattern letters that can be used when formatting dates.

share|improve this answer
1  
Can I put that in a visual force email template? –  dublintech Dec 17 '12 at 11:29
    
I've updated my example for the visualforce page use. –  mast0r Dec 17 '12 at 12:33
TEXT(DAY(TODAY()))&" "&CASE(MONTH(TODAY()),1,"January",2,"February",3,"March",4,"April",5,"May",6,"June",7,"July",8,"August",9,"September",10,"October",11,"November","December")&" "&TEXT(YEAR(TODAY()))

Try this formula instead than coding .

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.