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
VarunSVarunS 

Start Date & End Date Validation Rule

Hi Guys, 

I have a two date fields as Start Date and End Date and a picklist field having two values as week and month, I need a validation rule like: If i select week in the picklist field that the no. of days between End Date and Start Date should not be more than 7 and if I select month in the picklist field than the no. of days between End Date and Start Date should not be more than 30 days, can i get any help in this 
Best Answer chosen by VarunS
Rahul kumar 195Rahul kumar 195
Try with this. It will work fine in your case
  1. IF( ISPICKVAL( PlanFor__c , "Week") , 
    ((EndDate__c - StartDate__c)>=7) , 
    ((EndDate__c - StartDate__c)>=30)
    )
Thanks
Rahul

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Please try below validation rule. I hope that will help you
OR(
	AND(		
	   ISPICKVAL( Picklist__c , "month"),
	   EndDate__c - Start_Date__c >30	
	),
   
	AND(		
	   ISPICKVAL( Picklist__c , "week"),
	   EndDate__c - Start_Date__c > 7	
	)
)
Let us know if this will help you

Thanks
Amit Chaudhary

 
Rahul kumar 195Rahul kumar 195
Try with this. It will work fine in your case
  1. IF( ISPICKVAL( PlanFor__c , "Week") , 
    ((EndDate__c - StartDate__c)>=7) , 
    ((EndDate__c - StartDate__c)>=30)
    )
Thanks
Rahul
This was selected as the best answer
VarunSVarunS
Thanks Amit
VarunSVarunS
Thanks Rahul