I am struggling with something I think should not be difficult but I am not able to figure out, my date field display as the below screenshot.

enter image description here

My aim is to remove from the template the characters 00:00:00 GMT 2020 The field is date type, and I am sending to the visualforce component in the following way, then the visualforce component read the field as String

Email Template Content:

<messaging:emailTemplate recipientType="User" relatedToType="SBQQ__Quote__c" subject="Quote {!relatedTo.Name} requires Trial Request">   
<messaging:htmlEmailBody > 

     <c:CPQComponent quoteId="{!relatedTo.id}" accountName="{!relatedTo.SBQQ__Account__r.Name}" 

Visualforce Component Portion Code:

<apex:component controller="CPQ_CSTrialRequestController" access="global">
<apex:attribute name ="trialRequestShipDate" type="String" description="Trial Requested Ship Date" assignTo="{!quote_TrialRequestShipDate}"/>
<font color="#58595b" face="Arial,Verdana,Trebuchet MS,Helvetica,sans-serif" style="font-size:16px; line-height: 24px;">{!quote_TrialStartDate}</font></td>

Do you recommend me other approach?


  • is Requested_Ship_Date__c really a Text data type and not a Date datatype?
    – cropredy
    Jun 16 '20 at 15:55
  • It is a Date datatype
    – l13
    Jun 16 '20 at 15:56
  • Then the component data type should be Date and you can use standard date formatting via apex:Param to get what you need
    – cropredy
    Jun 16 '20 at 15:58
  • Thank you for your support. @cropredy. I changed to Date but I am facing now the following error: Incorrect parameter type for operator '-'. Expected Number, Date, DateTime, received Text. I think i faced before I tried with Date type
    – l13
    Jun 16 '20 at 16:25
  • your component controller property called trialRequestShipDate needs to use Date as well; I presume you know about VF formatting dates using outputText
    – cropredy
    Jun 16 '20 at 17:28

Here is your issue:

The field passed to the VF component is of type Date


The component defines it as type String

<apex:attribute name ="trialRequestShipDate" type="String" 

And the VF Component controller would also have been defined as type String

public String trialRequestShipDate {get; set;}

To fix, both the <apex:attribute> and the VF component property should be of type Date

You'll then be able to easily format the value as you want using <apex:outputText> using this VF field formatting reference

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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