3

How can i get the date on the date/time record type. So that i can condition this if Start_Date_Time__c = End_Date_Time__c. If true the output is like this:

Friday, 26 June 2015 from 9:00 AM to 9:00 PM (Greenwich Mean Time)

If false the output may like this:

From Monday, 29 June 2015 , 3:13 PM to Tuesday, 30 June 2015 , 3:13 PM (Greenwich Mean Time)

here is my vf code:

< apex:outputText value="{!IF(Event__c.Start_Date_Time__c = Event__c.End_Date_Time__c, "{0,date, EEEEE',' d MMMM yyyy ',' h:mm a} to {1,date, h:mm a '('zzzzz')'}", "From {0,date, EEEEE',' d MMMM yyyy ',' h:mm a} to {1,date, EEEEE',' d MMMM yyyy ',' h:mm a '('zzzzz')'}")}"/><br/>
<apex:param value="{!Event__c.Start_Date_Time__c+(8/24)}" /> 
<apex:param value="{!Event__c.End_Date_Time__c+(8/24)}" /> 
</apex:outputText>

The condition still wrong because of the time was included. I just want to condition it with the date only. Is this possible. Hope you get me.Thank you in advance.

1

Try something like this:-

<apex:outputText rendered="{!DATEVALUE(Event__c.Start_Date_Time__c) == DATEVALUE(Event__c.End_Date_Time__c)}" value="From {0,date, EEEEE',' d MMMM yyyy ',' h:mm a} to {1,date, EEEEE',' d MMMM yyyy ',' h:mm a '('zzzzz')'}">
<apex:param value="{!Event__c.Start_Date_Time__c+(8/24)}" /> 
<apex:param value="{!Event__c.End_Date_Time__c+(8/24)}" /> 
</apex:outputText>

<apex:outputText rendered="{!DATEVALUE(Event__c.Start_Date_Time__c) != DATEVALUE(Event__c.End_Date_Time__c)}" value="{0,date, EEEEE',' d MMMM yyyy ',' h:mm a} to {1,date, h:mm a '('zzzzz')'}">
<apex:param value="{!Event__c.Start_Date_Time__c+(8/24)}" /> 
<apex:param value="{!Event__c.End_Date_Time__c+(8/24)}" /> 
</apex:outputText>

DateValue should give you what you need. I've also split the criteria out into a rnedered attribute to make reading easier.

| improve this answer | |
  • Yeah.. just noticed.. the condition (operator) was interchange.. thanks anyway.. – Lennon Leopoldo Jun 26 '15 at 3:23
1

You can create a checkbox formula field and use the value on your visualforce page. If dates are the same, the checkbox will be true automatically. Otherwise it will remain it as false.

Remember that sometimes platform offers functionality you can use and you don't need code #clicksnotcode

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.