From my understanding you have four columns
EndDate2. I'll shorten these to
E2respectively. The final equation will use the full names at the bottom of the post. If the validation doesn't work, please let me know.
To put list validation on, you have to go to List Settings > Validation Settings as per this image below. Column validation doesn't allow for multi-column validation, AFAIK.
E1 are always required.
E2 are only occasionally required. If one is filled out, the other must also be filled.
En must be in chronological order (ie
S1 < E1)
For this we can take
E1 and mark them required in the column definition to save some additional logic in the item validation.
List validation triggers when an expression equates to
To check if an item is greater than we can ask
S1 < E1 AND S2 < E2 If those both hold up, we get a true return. If not, we get a false return. In SharePoint this turns into
=AND(StartDate1 < EndDate1, StartDate2 < EndDate2)
Now we also need the conditionally required columns,
E2. Check out the table below. We want to evaluate to
S2 Present | E2 Present || Valid?
F | F || T
F | T || F
T | F || F
T | T || T
We need a
TRUE for both empty, and a
TRUE for both full to get the proper
FALSE values. So if we have
(S2 AND E2) OR (NOT S2 AND NOT E2) we'd get...
Now we need both conditions to be
TRUE in order to pass the validation, so that implies an AND condition. We can add the bottom, longer, condition to the previous AND condition. The final validation string should be:
StartDate1 < EndDate1,
StartDate2 < EndDate2,