How to filter OData by a month?

Dear forum Team,
I would like to fetch all Entities of Type "Projektzeit" from a table. The Entity has a property of type date which I want to filter using an OData request and I only want those whose date is in the last month.

My idea was first to first get the entities entirely through a custom method, however since this simple action should be able to be done using OData, I am sure.

So how can I

a) Get the current last month as a property to filter for or
b) filter them directly in a $filter command?

Thanks in advance

There are a few ways to filter by month in OData.

Use month function:

$filter=month(MyDate) eq 1

Use range:

$filter=MyDate gt datetime'2010-01-01' and MyDate lt datetime'2010-01-31'


1 Like