+ Start a Discussion
lil_rangerlil_ranger 

Help in displaying fields when not null

<div style = "{!IF(Contract.Training_Start_Date__c != null,'','display:none;')}">
<tr>
<th><b><u>Date(s) of Service</u></b></th>
</tr>
<tr>
<td>Start: <apex:outputText value="{0, date, MMMM d, yyyy}">  <apex:param value="{!Contract.Training_Start_Date__c}"/></apex:outputText><br />
End: <apex:outputText value="{0, date, MMMM d, yyyy}"> <apex:param value="{!Contract.Training_End_Date__c}"/></apex:outputText></td>
</tr>
</div>

 Can someone tell me why the Start and End dates will not display in my page when they are not null?

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

I don't think you can compare against null like that.  Try using ISNULL,  e.g.

 

div style = "{!IF(NOT(ISNULL(Contract.Training_Start_Date__c)),'','display:none;')}">
<tr>
<th><b><u>Date(s) of Service</u></b></th>
</tr>
<tr>
<td>Start: <apex:outputText value="{0, date, MMMM d, yyyy}">  <apex:param value="{!Contract.Training_Start_Date__c}"/></apex:outputText><br />
End: <apex:outputText value="{0, date, MMMM d, yyyy}"> <apex:param value="{!Contract.Training_End_Date__c}"/></apex:outputText></td>
</tr>
</div>

 

All Answers

bob_buzzardbob_buzzard

I don't think you can compare against null like that.  Try using ISNULL,  e.g.

 

div style = "{!IF(NOT(ISNULL(Contract.Training_Start_Date__c)),'','display:none;')}">
<tr>
<th><b><u>Date(s) of Service</u></b></th>
</tr>
<tr>
<td>Start: <apex:outputText value="{0, date, MMMM d, yyyy}">  <apex:param value="{!Contract.Training_Start_Date__c}"/></apex:outputText><br />
End: <apex:outputText value="{0, date, MMMM d, yyyy}"> <apex:param value="{!Contract.Training_End_Date__c}"/></apex:outputText></td>
</tr>
</div>

 

This was selected as the best answer
lil_rangerlil_ranger

Thank you.  It worked perfectly!