Hello everyone, I would like to know how to add a “between” filter to take a value between 2 dates.
Here is the code I did:
if (inputBecameStart !== "undefined" && inputBecameEnd !== "undefined" && statut !== "undefined") { let dateEnd = inputBecameEnd; let dateStart = inputBecameStart; let filter = { propertyName: "hs_lifecyclestage_"+statut+"_date", operator: "BETWEEN", value: new Date(dateStart).toISOString(), highValue: new Date(dateEnd).toISOString() } PublicObjectSearchRequest.filterGroups[0].filters[i] = filter; i++;}
but I have this error: ‘Invalid input JSON on line 1, column 135: operator BETWEEN requires a highValue’
which I do not understand because for me I have already put highValue thank you for trying to help me understand this error 
Hey @RKINZELIN ,
Since you’re using the toISOString method, I assume your dates would result in something like this:
“2023-04-24T12:34:56.789Z”
However, HubSpot expects Unix timestamps in milliseconds here. So something like this:
1682340819000
If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I’d really appreciate it.
Cheers,
Chriso
hello Chriso-mwx,
yes I tried the same but without success with the same error while I put the high value 
let filter1 = { propertyName: "hs_lifecyclestage_"+statut+"_date", operator: "BETWEEN", value: new Date(dateStart).getTime(), highValue: new Date(dateEnd).getTime()}PublicObjectSearchRequest.filterGroups[filterCount].filters[i] = filter1;
Hey @RKINZELIN ,
can you give a bit more context? It’s best for the community to get the bigger picture, so they have the best chance of helping you. Like, for example, what would be an example of a value in the inputBecameStart variable? Where is the PublicObjectSearchRequest being set? What else have you tried? Did you pass the UNIX timestamps as strings instead of an integer before?
I can’t really test this case, unfortunately, as I can’t tell what exactly is going.
Best,
Chriso
Hey Chriso-mwx,
I make a program that allows to take some contacts according to filter and therefore at the beginning of my main function I initialize my
PublicObjectSearchRequest like this:
let PublicObjectSearchRequest = { filterGroups : [{filters:[]}], sorts: [""], query: "", properties: ['firstname', 'lastname', 'email', 'phone', 'page_views'], limit: 0, after: 0 };
then I add all the filters except between which are specific
let i = 0;let filterCount = 0; if (filtres.length !== 0) { filtres.forEach(element => { let filtre = { propertyName: element.propertyName, operator: element.operator, value: element.value } PublicObjectSearchRequest.filterGroups[filterCount].filters.push(filtre); i++; if(i===3){ filterCount++; i=0; PublicObjectSearchRequest.filterGroups[filterCount] = {filters:[]}; } }); }
Finally, I create the filter with the between as I sent you just before which generates the error that I do not understand since it does not recognize at all the “highValue” that I put. For the value I tried all (string, float, int) sde same for the format but the error clearly shows that it does not find the highValue at all.
Hey,
I’m sorry to tell you this but for me your filter with “BETWEEN” as operator does not work. 