Skip to main content
Solved

Get Events API: is there a way to pass a date range

  • February 7, 2023
  • 4 replies
  • 262 views

Forum|alt.badge.img+2
  • Contributor I
  • 2 replies

I’m using the Get Events API (2023-01-24) and trying to get events using a filter that includes events that occurred greater than or equal to {{date 1}} and less than {{date 2}}.   I'm able to successfully get data using greater-than-equal, but as soon as I add “and” and the ‘less than’ date, I get a 400.  Could be the filter is incorrect.. but hoping someone has an example.  Here is what we are currently passing:

?filter=and(greater-or-equal(datetime,1970-01-01T12:00:00Z), less-than(datetime,2023-02-07T17:40:09.274Z))

Best answer by Brian Turcotte

Hi@LoriM!

 

I’m so sorry for the delay in response here!

 

Unless I’m mistaking your intent, I don’t believe you need the “and” logic to include both the greater-or-equal and less-than modifiers. We did some testing, and a call in this format should yield the desired results:

{{baseUrl}}/api/events/?filter=greater-or-equal(datetime,2022-04-01T11:30:00Z),less-than(datetime,2022-07-01T11:30:00Z)

 

If you remove the and statement, does the error still persist?

 

Thanks,

Brian

View original
Did this topic or the replies in the thread help you find an answer to your question?

4 replies

Brian Turcotte
Forum|alt.badge.img+37

Hi @LoriM and welcome to the Community!

 

From my perspective, it looks like the call is formatted correctly, so I am going to reach out to Engineering to see if they can provide some more context here. Especially since this other Community member mentioned the exact same issue on the same day, here:

 

I will update the thread as soon as I learn more about what could be causing this. 

 

Thanks for using the Community!

- Brian


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 2 replies
  • February 21, 2023

Hi Brian - I was just curious if you had heard anything back on this one yet.  Thanks!


Brian Turcotte
Forum|alt.badge.img+37
  • Klaviyo Alum
  • 1393 replies
  • Answer
  • March 20, 2023

Hi@LoriM!

 

I’m so sorry for the delay in response here!

 

Unless I’m mistaking your intent, I don’t believe you need the “and” logic to include both the greater-or-equal and less-than modifiers. We did some testing, and a call in this format should yield the desired results:

{{baseUrl}}/api/events/?filter=greater-or-equal(datetime,2022-04-01T11:30:00Z),less-than(datetime,2022-07-01T11:30:00Z)

 

If you remove the and statement, does the error still persist?

 

Thanks,

Brian


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 2 replies
  • March 21, 2023

yes, that worked, thank you Brian!