# V3 Search - 400 Bad Request when using BETWEEN

**URL:** <https://community.hubspot.com/t/v3-search-400-bad-request-when-using-between/80894>\
**Category:** APIs & Integrations\
**Tags:** object\
**Created:** [May 10, 2023, 8:14am UTC](https://community.hubspot.com/t/v3-search-400-bad-request-when-using-between/80894 "2023-05-10T08:14:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jensonB](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jensonB](https://community.hubspot.com/u/jensonB)\
**Post date:** [May 10, 2023, 8:14am UTC](https://community.hubspot.com/t/v3-search-400-bad-request-when-using-between/80894/1 "2023-05-10T08:14:23Z")

</div>

Hello,  
I try to setup the hubspot PHP API and get deals using the search (V3): /crm/v3/objects/deals/search  
My problem is that always when I integrate the BETWEEN operator a 400 Bad request response is returned. Without the filter it works.  
In my code example I use a filter 1 (which works) and filter 2 (BETWEEN on a custom field). Filter 2 was tested with the custom field but also with a lastmodifieddate.

The customfield “datum\_unterschrift” is formatted as Y-m-d and in the result without filter2 it is named and formatted exactly as expected.

Tested with lastmodifieddate using the propertyname “lastmodifieddate” as well as “hs\_lastmodifieddate” with value/highvalue date with milliseconds

**Error:**

_Exception when calling search\_api-\>do\_search: [400] Client error: `POST [https://api.hubapi.com/crm/v3/objects/deals/search\`](https://api.hubapi.com/crm/v3/objects/deals/search%5C%60) resulted in a `400 Bad Request` response: {“status”:“error”,“message”:“There was a problem with the request.”,“correlationId”:"a7d3088a-e7f5-4302-a771-ae6d5350d7f (truncated…)_

**Code:**

```lia-code-sample
$client = Factory::createWithAccessToken(config('hubspot.key'));

 $filter1 = new Filter([
 'value' => 'decisionmakerboughtin',
 'property_name' => 'dealstage',
 'operator' => 'EQ'
 ]);

 $filter2 = new Filter([
 'value' => '2023-02-01T00:00:00.000Z',
 'high_value' => '2023-05-01T00:00:00.000Z',
 'property_name' => 'hs_lastmodifieddate',
 'operator' => 'BETWEEN'
 ]);

 $filterGroup1 = new FilterGroup([
 'filters' => [$filter1,$filter2]
 ]);

 $publicObjectSearchRequest = new PublicObjectSearchRequest([
 'filter_groups' => [$filterGroup1],
 'sorts' => ['created_at'],
 'properties' => ["dealname,amount,recurring_revenue_amount,dealstage,datum_unterschrift"],
 'limit' => 100,
 'after' => 0,
 ]);

```

Thanks

---

<div class="post-metadata">

**Author:** ![skimura](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@skimura](https://community.hubspot.com/u/skimura)\
**Post date:** [May 11, 2023, 5:45am UTC](https://community.hubspot.com/t/v3-search-400-bad-request-when-using-between/80894/2 "2023-05-11T05:45:06Z")

</div>

@jensonB

Hi.

How about try this?

```lia-code-sample
...
$filter2 = new Filter([
 // unixtime
 'value' => '1675209600000',
 // unixtime
 'high_value' => '1682899200000',
 'property_name' => 'hs_lastmodifieddate',
 'operator' => 'BETWEEN'
]);
...

```

I referenced the following.

> **[Search the CRM - HubSpot docs](https://developers.hubspot.com/docs/api-reference/latest/crm/search-the-crm)**
>
> The CRM search endpoints make getting data more efficient by allowing developers to filter, sort, and search across any CRM object type.

Thanks.
