Question

Filtering odata request by date

I am looking to filter an odata request within power automate to return only records where the modifiedon date is greater than a specified value. I have thus far tried the following without success:

 

$filter=ModifiedOn%20gt%20datetime'2023-05-23T00:00:00.0000000Z'

 

{ "error": { "code": "", "message": "The query specified in the URI is not valid. Unrecognized 'Edm.String' literal 'datetime'2023-05-23T00:00:00.0000000Z'' at '14' in 'ModifiedOn gt datetime'2023-05-23T00:00:00.0000000Z''.", "innererror": { "message": "Unrecognized 'Edm.String' literal 'datetime'2023-05-23T00:00:00.0000000Z'' at '14' in 'ModifiedOn gt datetime'2023-05-23T00:00:00.0000000Z''.", "type": "", "stacktrace": "" } } }

 

$filter=ModifiedOn%20gt%20cast('2023-05-23T00:00:00.0000000Z','Edm.DateTimeOffset')

 

{ "error": { "code": "", "message": "The query specified in the URI is not valid. The binary operator GreaterThan is not defined for the types 'System.Nullable`1[System.DateTime]' and 'System.Object'.", "innererror": { "message": "The binary operator GreaterThan is not defined for the types 'System.Nullable`1[System.DateTime]' and 'System.Object'.", "type": "", "stacktrace": "" } } }

 

$filter=ModifiedOn%20gt%20'2023-05-23T00:00:00.0000000Z'

 

{ "error": { "code": "", "message": "The query specified in the URI is not valid. A binary operator with incompatible types was detected. Found operand types 'Edm.DateTimeOffset' and 'Edm.String' for operator kind 'GreaterThan'.", "innererror": { "message": "A binary operator with incompatible types was detected. Found operand types 'Edm.DateTimeOffset' and 'Edm.String' for operator kind 'GreaterThan'.", "type": "", "stacktrace": "" } } }

 

$filter=ModifiedOn%20gt%20datetimeoffset'2023-05-23T00:00:00.0000000Z'

 

{ "error": { "code": "", "message": "The query specified in the URI is not valid. Unrecognized 'Edm.String' literal 'datetimeoffset'2023-05-23T00:00:00.0000000Z'' at '14' in 'ModifiedOn gt datetimeoffset'2023-05-23T00:00:00.0000000Z''.", "innererror": { "message": "Unrecognized 'Edm.String' literal 'datetimeoffset'2023-05-23T00:00:00.0000000Z'' at '14' in 'ModifiedOn gt datetimeoffset'2023-05-23T00:00:00.0000000Z''.", "type": "", "stacktrace": "" } } }

 

Any suggestions for how to achieve this would be much appreciated. Thanks.

Like 0

Like

2 comments

This works for me

$filter=ModifiedOn gt 2024-05-14T00:00:00Z

I don't know if there is something specific for power automate, but in just accessing the Creatio odata api this is valid.

Ryan

Hello,

 

The correct way to format the filter in your OData request is by using the Edm.DateTimeOffset type directly, but the format should be specific. Here’s how you can do it:

https://website/yourentity?$filter=ModifiedOn gt 2023-05-23T00:00:00Z

Show all comments