It seems that your startDateTime is greater than endDateTime.
try to find out what is inside:
X++:
info(strFmt("%1 %2", startDateTime, endDateTime));
Next step is to define conditions correctly. I guess you missed braces, because AND priority is higher than OR.
X++:
where docuRef.RefTableId == tableNum(CustTable) &&
docuRef.RefCompanyId == curext() &&
(docuRef.createdDateTime >= startDateTime &&
docuRef.createdDateTime <= endDateTime &&
docuRef.TypeId == #SPP) || docuRef.TypeId != #SPP