 ShowAll Questionssorted byDate Posted Anu Sharma 54

# Hi, i have two field start date and end date I want to validation that is end date must be in between 2 to 6 month only How can i do that.

Hi,
i have two field start date and end date I want to validation that is end date must be in between 2 to 6 month only How can i do that. Best Answer chosen by Anu Sharma 54 ccz
Hi Anu,

First, create a formula field ( Months Between ) which returns number

IF(NOT(ISBLANK(End_Date__c)) && NOT(ISBLANK(Start_date__c))
,(((YEAR(End_Date__c ) - YEAR(Start_Date__c ) - 1) *12) + (12 - MONTH(Start_Date__c ) +1) + MONTH(End_Date__c ) - 1+ IF(DAY(End_Date__c ) > DAY(Start_Date__c ),1,0)))
, null
)

After that create the following validation rule

((Months_Between__c ) < 2) || ((Months_Between__c) > 6)

Thanks
Good luck ccz
Hi Anu,

First, create a formula field ( Months Between ) which returns number

IF(NOT(ISBLANK(End_Date__c)) && NOT(ISBLANK(Start_date__c))
,(((YEAR(End_Date__c ) - YEAR(Start_Date__c ) - 1) *12) + (12 - MONTH(Start_Date__c ) +1) + MONTH(End_Date__c ) - 1+ IF(DAY(End_Date__c ) > DAY(Start_Date__c ),1,0)))
, null
)

After that create the following validation rule

((Months_Between__c ) < 2) || ((Months_Between__c) > 6) Anu Sharma 54 ccz