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
lewislewis 

validation rule for dates

i have a parent & child object that has a start and end date  . I need a rule that whenever a start/end date is added in the child record, it checks the date is the same or within the date range as shown in the parent record.

Steve :-/Steve :-/

What is the relationship between the Parent and Child?  If it's Master-Detail you might be able to create Rollup Summary (RS) fields on the Master that return the MAX and MIN Dates from the Child object and a VR that will throw an error if the Child Date is outside the range.

lewislewis

so u r saying i shld create two roll up summary fields in the master object and 2 validation rules ? canu be more clearer on the validation rule ?

Navatar_DbSupNavatar_DbSup

Hi,

 

you can achieve this trough the validation. Here I have taken Start_D__c   as contact start date and

Account.Start_Date__c, Account.End_date__c as account start and end date.

Hence validation should be like this:

 

(Start_D__c  <  Account.Start_Date__c)  || ( Start_D__c >= Account.End_date__c )


Similarly you can write the validation for your end date also.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

lewislewis

am getting an error in this and would like some help

 

( End_Date__c < account_Start__c ) || ( End_Date__c>= account_End__c )

 if the end date is similar to the account end date then it gives and error . i need to show that the dates need to be the same as the account dates or within the date range .

 

thanks

Steve :-/Steve :-/

Try something like:

AND( 
End_Date__c < account_Start__c, 
End_Date__c >= account_End__c )