Check for ovelaping start and end dates between requests

0
Hello,   I have a form where I can submit a request where I input a separate start and end date. Now I want to add a validation that would not allow me to submit a request if the start or end dates are matching and overlapping with an existing request.   So for example if I have a request with start date 11/10, end date 11/15, it should not allow me to submit a request that has a start or end date that is matching with either existing start/end dates, as well as if the new request dates are between 11/10-11/15, for example start or end date would be 11/12, it shouldn't allow to submit such a request.   I tried using the below xpath: new request EndDate>IteratorStartDate and new request StartDate<IteratorEndDate   also many extra validations like new request start date = iterator start date, new request end date = iterator end date and so on but it doesn't work as expected.   Perhaps anyone has encountered such a use case?   Thank you!    
asked
1 answers
0

Hey Aidas ;) 

 

The simplest idea is to check as following 

 

(StartDate1 <= EndDate2) and (StartDate2 <= EndDate1)

 

If this condition is met then the Date1 and Date2 intervals are overlapping

 

And you can retrieve a request with a different id than the current one you're creating with the condition above. If one exists then you have found an invalid case 

 

 

answered