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
nununinununi 

Formula field showing #Error!

The following formula is shoing an error. 
DATE( 
YEAR(CurrentEndDate__c + GracePeriod__c ),
(MONTH(CurrentEndDate__c + GracePeriod__c)+1), 
(1) 
)-1

CurrentEndDate__c = 11/30/2015
GracePeriod__c = 30

Please help!
Best Answer chosen by nununi
Ronald OlechRonald Olech
The error is because during the months of November and December the value of (MONTH(CurrentEndDate__c + GracePeriod__c)+1) is going to be 13 and 14. 

I would recommend separating this in three formulas with a nested IF statement
IF ((MONTH(CurrentEndDate__c + GracePeriod__c)+1)<13, {use formula above},IF((MONTH(CurrentEndDate__c + GracePeriod__c)+1)<14,{formula for November},{formula for December},))
 

All Answers

Matthias ThalMatthias Thal
Please Try (not tested)

DATE( 
YEAR(CurrentEndDate__c + GracePeriod__c),
MONTH(CurrentEndDate__c + GracePeriod__c) + 1, 
1
)- 1
Ronald OlechRonald Olech
The error is because during the months of November and December the value of (MONTH(CurrentEndDate__c + GracePeriod__c)+1) is going to be 13 and 14. 

I would recommend separating this in three formulas with a nested IF statement
IF ((MONTH(CurrentEndDate__c + GracePeriod__c)+1)<13, {use formula above},IF((MONTH(CurrentEndDate__c + GracePeriod__c)+1)<14,{formula for November},{formula for December},))
 
This was selected as the best answer