function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Compass 1Compass 1 

How to check field value is Date or Number or String

I have created one page to show the Opportunity History but when the output comes wherever the changed value is date is shows in "Fri Feb 20 00:00:00 GMT 2015 " format whereas I wanted to show in "20-Feb-2015" format. 
But also in the old value and new value field it could be Number or String Value. How to fix this format problem please advise.

For reference please find below my page code,

<apex:datatable value="{!opportunityHistoryList}" var="opp" width="100%" styleClass="tableClass" border="1">
<apex:column value="{!opp.OpportunityId}" headerClass="headerstyle" headerValue="Opportunity ID"/>
<apex:column value="{!opp.CreatedById}"  headerClass="headerstyle" headerValue="Changed By"/>
<apex:column value="{!opp.CreatedDate}" headerClass="headerstyle" headerValue="Changed Date"/>
<apex:column value="{!opp.Field}" headerClass="headerstyle" headerValue="Field"/>
<apex:column value="{!opp.OldValue}"  headerClass="headerstyle" headerValue="Old information"/>
<apex:column value="{!opp.NewValue}"  headerClass="headerstyle" headerValue="New Information"/>
</apex:datatable>

 
Zuinglio Lopes Ribeiro JúniorZuinglio Lopes Ribeiro Júnior
Hello,

If I got it right you are using the field as polymorphic, am I right? If so, I suppose this field is a text field. Are you using a custom controller in your VF?

Regards
Compass 1Compass 1
yes this is the text field. its system field to capture field history.
Yes i am using the custom controller to fetch the full list of OpportunityFieldHistory with simple Select command.
Zuinglio Lopes Ribeiro JúniorZuinglio Lopes Ribeiro Júnior
Hello,

Text fields doesn't change the format of its values, I believe the date is being stored in that format. How are you setting the values in that field?

Regards.
David OvellaDavid Ovella
Hello,
If you want the date looks like this 20-feb-2015 try
<apex:column value=" {!opp.CreatedById}"  headerClass="headerstyle" headerValue="Changed By"/>
see the space betwen " {