Webinar (on-demand): OutSystems and Analytics Integration: A New Strategy to Reduce Costs

Discover everything you need to know about Hubway Connect

Try the product online without any installation or purchase commitment
Hubway Connect

Innovative ways to leverage your data for business outcomes

Find out how Hubway Connect can help you get more value from your OutSystems platform
Hubway Connect

Learn and expand your Hubway Connect knowledge

Deep dive in articles, videos and technical information to maximise its use
Hubway Connect

Start free and expand without surprises

Choose the Hubway Connect offer that best meets your needs and suits your budget
Hubway Connect

We are here to help. Let’s talk.

Connect with us via your preferred channel and we will be happy to answer your questions
Hubway Connect
  1. Home
  2. Knowledge Base
  3. FAQs
  4. How to filter by date and time in OData

How to filter by date and time in OData

In OData, you can use the $filter query option to filter data based on certain conditions, including date filtering.

 

Example:

Suppose you have an entity called “Orders,” and it has a property called “OrderDate” representing the date of the order. You want to retrieve all orders that were placed after a specific date, let’s say January 1, 2023.

 

The OData URL for this filter would look like:

/Orders?$filter=OrderDate gt 2023-01-01

 

In this example:

/Orders is the endpoint for the “Orders” entity.

$filter is the query option used to filter the data.

OrderDate gt 2023-01-01 specifies the condition. It filters orders where the “OrderDate” is greater than (after) January 1, 2023.

 

In OData, filtering based on date and time typically involves using the format ‘yyyy-MM-ddTHH:mm:ssZ’ to represent date and time values, where:

  • ‘yyyy’ represents the 4 digit year (e.g. 2015)
  • ‘MM’ represents the month number with leading zero (eg.04)
  • ‘dd’ represents the day of the month as a number from 01 through 31
  • ‘HH’ represents the 24-hour clock hour, with a leading 0 (e.g. 22)
  • ‘mm’ represents the minutes with a leading zero
  • ‘ss’ represents the seconds with leading zero

 

Example:

Suppose you have an entity called “Events,” and it has a property called “EventDateTime” representing the date and time of the event. You want to retrieve all events that occurred after a specific datetime, let’s say February 15, 2023, at 3:30 PM.

 

The OData URL for this filter would look like:

/Events?$filter=EventDateTime gt 2023-02-15T15:30:00Z

 

In this example:

/Events is the endpoint for the “Events” entity.

$filter is the query option used to filter the data.

EventDateTime gt 2023-02-15T15:30:00Z specifies the condition. It filters events where the “EventDateTime” is greater than (after) February 15, 2023, at 3:30 PM.

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support