How to do a flow query by retrieving the data whose endDate field is greater than the current date or not filtering if the field is empty or null

I want to do a flow query by retrieving the data whose endDate field is greater than the current date or not filtering if the field is empty or null.

After my research, it seems that I have to use filter, but I don’t know how to do it.

Below is my implementation that doesn’t work.

return $this->query()
            ->find("[instanceof TC.Calendar:Document.AbstractEvent][_hidden=false]")
            ->filter('[endDate=""],[endDate >= "' . (new DateTimeImmutable())->format('d-m-Y H:i') . '"]')
            ->sort('startDate', 'ASC')
            ->get();

NB: in PHP and not in fusion

Hello everyone, it’s been 2 weeks now that I’m confronted with the filtering of my data based on a datetime field. I can’t find any documentation explaining how to filter data based on a DateTime field.
I am a new developer in this CMS.

I am asking for help to advance my project. Thanks

Hi,

you can use the filterByDate operation from this package: Flowpack.Listable/FilterByDateOperation.php at master · Flowpack/Flowpack.Listable · GitHub

Either by installing the package or by integrating this operation into your project.

Hope that helps.

2 Likes

@sebobo Thanks a lot for the feedback, I’ll install it and test it, then get back to you. Thanks again for the feedback.

@sebobo Thanks, this work perfectly.

1 Like