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
6262 

how to add a date field to my V'force page?

b-Forceb-Force

You can add/bind date field in VF page in same  as other input fields , by using <Apex:inputField/> tag.

 

To show date in readonly format you can use outputtext or outputLabel

 

Sample code

<apex:inputField value='{!DateField}' />

 

To format date value in diffrent formats you can use Date.format() functions, with various parameters based on requiremnt

 

 

Regards,

bForce

goabhigogoabhigo

Use outputField if you want the field to be read only and inputField if it can be edited.

 

<apex:outputField value="{!YourObject.dateField}"/>

 

If it is custom field then you have to add __c.

goabhigogoabhigo

outputField shows with the standard format of date based on your locality setting like - dd/mm/yyyy or mm/dd/yyyy. Note that the separator here is /. Now if you want different format, say separator as -, then make use of outputText as following,

 

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

goabhigogoabhigo

Is the problem solved? Let me know if you need more clarifications..