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
alok29novalok29nov 

Date Issue (Adding two dates)

Hi all,

 

I have two fields Average_Sales_Cycle__c and Booking_Date__c.

Average_Sales_Cycle__c        Number(18, 0)

Booking_Date__c                     Date

 

I want to add both these fields and get the added value as a date. I am querying these two fields in a btach apex and trying to add both like below.

 

Date BookingDate=opp1.Date_Opened__c+opp1.Average_Sales_Cycle__c

 

but getting an error "Date arithmetic expressions must use Integer or Long arguments at line 85 column 40".

 

How can I achieve this and I also want to compare the month of BookingDate against 1 to 12.

 

Please let me know how this can be achieved.

 

Thanks

~Alok

 

 

Best Answer chosen by Admin (Salesforce Developers) 
alok29novalok29nov

Got the issue now..Below format resolved my issue.

 

opp1.Date_Opened__c+Integer.valueof(opp1.Average_Sales_Cycle__c)