0

My Formula field I have the code for below :

Integer d = CloseDate.day();
Integer mo = CloseDate.month();
Integer yr =  CloseDate.year();

DateTime DT = DateTime.newInstance(yr, mo, d);
Time Difference (Date/Time) =  Calculating_Date__c  - DT;

Here In Opportunity I try to get the date/Time difference in the date field(Close Date) and date/time field(Calculating Date) to display the difference in the result in date/time field(Time Difference).

But I got this error

Error: Syntax error. Found 'Integer'

I don't know how to be rectified in this error in here.

So please help me to complete the task. For answer's thanks in advance.

1 Answer 1

1

Creating variables are not allowed in formula fields. You can directly write

DATETIMEVALUE(CloseDate) - Calculating_Date__c
4
  • Yes, Maruf Bagwan sir but I have difference fields date and date/time field
    – Raj
    Commented Oct 12, 2016 at 11:44
  • Here I want the make subtract the date and date time fields and the answer is in the date/time field so that's why I struggle here it makes confusion for me.
    – Raj
    Commented Oct 12, 2016 at 11:48
  • hi, i got your concern, I have updated the answer please check this one Commented Oct 12, 2016 at 11:53
  • Oops, I forget 2 datetime difference is alsways number, not date time so thanks for remember me Maruf.And for answer.
    – Raj
    Commented Oct 12, 2016 at 11:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .