I am trying to make a rest callout from one Salesforce org to another and I am using the following query in the rest end point

```
    DateTime sdt = DateTime.newInstance(startDate.year(), startDate.month(),startDate.day());
    String startDateFormat = sdt.format('yyyy-MM-dd 00:00:00');
    System.debug('startDateFormat ::::: '+startDateFormat);
    request.setEndpoint('callout:'+namedCredential+'/services/data/v56.0/query?'+
                        'q=select+Id,+Name,+Reference_Code__c,+Patient_name_anonymized__c,'+
                        '+Primary_Treatment__r.Name,+Amount,+date_of_treatment__c,'+
                        '+Consultation_Booking_Date__c,+StageName,+'+
                        '+Brand__r.Imprint_Address__c+from+Opportunity+where+date_of_treatment__c+<+'+startDateFormat+'+AND+Brand__c+in+('+brandIdString+')');

```

Here, I keep on getting null pointer exception even after I have formatted the date.

Is it not permitted to filter via a date field in the rest query?