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
Gary YantsosGary Yantsos 

Nested IF Problem

Hello. I'm having a problem with a complex nested IF condition. Just cant seem to get the syntax correct. Here is my condition-with my comments:

 

Line 1: Check to see if todayminus_365__c falls in between the start date and the end date.

Line 2: If it does, see if the first condition is less than or equal to the second condition.

Line 3: Check to see if this condition is greater than 366. If it is, my end value should be 365, otherwise its 0.

 

IF (todayminus_365__c   >=  Start_Date__c && todayminus_365__c <=  End_Date__c,

IF (End_Date__c -  todayminus_365__c <= 365, End_Date__c -  todayminus_365__c,

IF (End_Date__c -  todayminus_365__c > 366, 365,0)))

Best Answer chosen by Admin (Salesforce Developers) 
ManoharSFManoharSF

try 

IF (todayminus_365__c   >=  Start_Date__c && todayminus_365__c <=  End_Date__c,
IF (End_Date__c -  todayminus_365__c <= 365, End_Date__c -  todayminus_365__c,
IF (End_Date__c -  todayminus_365__c > 366, 365,0)), 0)

 

All Answers

ManoharSFManoharSF

try 

IF (todayminus_365__c   >=  Start_Date__c && todayminus_365__c <=  End_Date__c,
IF (End_Date__c -  todayminus_365__c <= 365, End_Date__c -  todayminus_365__c,
IF (End_Date__c -  todayminus_365__c > 366, 365,0)), 0)

 

This was selected as the best answer
Gary YantsosGary Yantsos

Worked perfectly! Thanks!