2

There are some codes like below:

<apex:outputText value="{!IF(item.FinishedDate__c == null, 'Not Finished', item.FinishedDate__c)}"/>

The item.FinishedDate__c is defined as Date, and I want the format of output is "yyyy-MM-dd", so I tried to modeify the codes like below but failed:

<apex:outputText value="{!IF(item.FinishedDate__c == null, 'Not Finished', {0,date,yyyy-MM-dd})}">
    <apex:param value="{!item.FinishedDate__c}" />
</apex:outputText>

Could someone help me? Thanks!

1
  • what exactly is the error message.
    – sunny
    Commented Apr 13, 2017 at 7:11

1 Answer 1

0

You can split the logic in two <apex:outputText and rendered it based on the condition item.FinishedDate__c==null or item.FinishedDate__c!=null. It will show Not Finished (first <apex:outputText) when your value is null and when the value is not null it will display the Date as per your required format (second <apex:outputText).

Note that the below code is not compiled one and you may have to fix any syntax error.

<apex:outputText value="Not Finished" rendered="{!item.FinishedDate__c == null}"></apex:outputText>
<apex:outputText value="{0,date,yyyy-MM-dd}" rendered="{!item.FinishedDate__c != null}">
    <apex:param value="{!item.FinishedDate__c}" />
</apex:outputText>
0

You must log in to answer this question.

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