Working with the Element API for the first time and I'm having a bit of a hard time finding any kind of documentation regarding writing more complex conditionals using the ElementCriteriaModel.

What I'm trying to accomplish, is selecting all entries (they are events with a start/end date as custom fields) from a given section, which overlap in any way with a passed-in query start/end date.

It is probably easier to simply supply the raw query that works, and perhaps someone could point me in the direction of documentation that could help me.

FROM craft_content
! ( field_eventStartDate > @queryStartDate AND field_eventStartDate > @queryEndDate)
! ( field_eventEndDate < @queryStartDate AND field_eventEndDate < @queryEndDate )

1 Answer 1


After doing a bit more digging, I think the only real option here is run a preliminary query to pull out the ids of the elements I want and then pass that into the ElementCriteriaModel. It's not ideal, but it'll do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.