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
newbee developernewbee developer 

SOQL query to display Modified Date without time

Hello All, Below is my query. 
MyItems = [SELECT Id,Title,LastModifiedById,LastModifiedDate 
                   FROM Knowledge__Kav WHERE Id IN :ProcessInstanceIds ORDER By LastModifiedDate DESC];
ProcessInstanceIds is a set of IDs from another object. 
This query doesnt order by Last Modified Date DESC.
Also, I want to display LastModifiedDate in Date Only format. 
Right now, it displays value as below:
11/18/2017 1:17 AM

I want to display as 11/18/2017
<apex:pageBlockTable value="{! MyItems }" var="r">
     <apex:column headerValue="Title">
      <a target="_blank" href= "/{!r.Id}" >{!r.title}</a>
      </apex:column>          
     <apex:column headerValue="Last Modified Date"><apex:outputfield value="{!r.LastModifiedDate}"/></apex:column>
     <apex:column value="{!r.CreatedById }" headerValue="CreatedBy"/>  
</apex:pageBlockTable>
Geetham Gai GodavarthiGeetham Gai Godavarthi
Hi newbee Developer,
Firstly create a formula field with return type date and then retrive the date from LastModifiedDate using that formula field and then use the newly created custom field to retrive the date.

Thanks 
Geetham.
Alain CabonAlain Cabon
Hello,

You can try this:
<apex:pageBlockTable value="{! MyItems }" var="r">
     <apex:column headerValue="Title">
      <a target="_blank" href= "/{!r.Id}" >{!r.title}</a>
      </apex:column>          
     <apex:column headerValue="Last Modified Date"><apex:outputfield value="{!r.LastModifiedDate}"/></apex:column>

     <apex:column headerValue="Last Modified Date 2">
        <apex:outputText value="{0, date, MM/dd/yyyy}">
            <apex:param value="{!r.LastModifiedDate}" /> 
        </apex:outputText>
     </apex:column>

     <apex:column value="{!r.CreatedById }" headerValue="CreatedBy"/>  
</apex:pageBlockTable>

<apex:outputText value="{0, date, MM/dd/yyyy}">  <apex:param value="{!r.LastModifiedDate}" /> 

0 is replaced by the first parameter (counting 0,1,2, ...)  and formated according the format used in java (1.5)