[SOLVED] Result between dates

I’m trying to make a request where I expect the result to be the records that have a date within a specific period, however the way I build this one generating an error, does anyone know how to do this?

Call:
https://cloud.squidex.io/api/content/my-squidex/my-service?$filter=data/dateField/iv ge datetime’2018-06-01T00:00:00’ and data/dateField/iv le datetime’2018-06-30T00:00:00’

Error:
{
“message”: “Query $filter clause not valid.”,
“details”: [
“Unrecognized ‘Edm.String’ literal ‘datetime’2018-06-01T00:00:00’’ at ‘23’ in ‘data/dataCriacao/iv ge datetime’2018-06-01T00:00:00’ and data/dataCriacao/iv le datetime’2018-06-30T00:00:00’’.”
],
“statusCode”: 400
}

Check out the tests, there is an example with datetime: https://github.com/Squidex/squidex/blob/master/tests/Squidex.Domain.Apps.Entities.Tests/Contents/OData/ODataQueryTests.cs

I followed the example of the “Should_make_query_with_datetime_equals” method and now I’m not getting an error, however the result is always empty, if I try to check the equality or only the larger the result is always the same, what can still be wrong?

Period:
https://cloud.squidex.io/api/content/my-squidex/my-service?$filter=data/dateField/iv ge 2018-06-01T00:00:00Z and data/dateField/iv le 2018-06-30T00:00:00Z

Equal (there is a record with the date ‘2018-06-06T18:57:50Z’):
https://cloud.squidex.io/api/content/my-squidex/my-service?$filter=data/dateField/iv eq 2018-06-06T18:57:50Z

Bigger or equal:
https://cloud.squidex.io/api/content/my-squidex/my-service?$filter=data/dateField/iv ge 2018-06-01T00:00:00Z

Answer (same for all tests):
{
“total”: 0,
“items”: []
}

Hi,

I think it could be a bug and will dig into it today.

Hi,
Any news on the problem? Is it really a bug?

Hi, I will start and probably fix it tomorrow. I am moving to a new apartment and another city and have family here to support me. Therefore I have to focus on that today.

Can you test it again? I deployed a fix.

1 Like

Hello Sebastian!

I hope that everything went well with your change of apartment, I tried again and got the same results that I described in my question of 03/08, that is, I do not receive an error but the result is always the same for the requests.

Hi Eduardo,

yes, everything went well and my new apartment is wonderful.

It works for me. See gif.

1 Like

Sebastian,

I found my error, I was keeping the time part in the filter, thank you!

How do you mean this? It also works with times for me.

I have a info with “dataCriacao” like “2018-08-08T12:32:17Z”.

If i put “$filter=data/dataCriacao/iv ge 2018-08-07” works.
If i put “$filter=data/dataCriacao/iv ge 2018-08-07T12:32:00Z” dont work.

Also works for me

Hi Sebastian,

Strange, very strange, see the tests I just did:

If i put “$filter=data/dataCriacao/iv ge 2018-08-07” works

If i put “$filter=data/dataCriacao/iv ge 2018-08-07T12:10:00Z” dont work.

For me it also works with your dates. Confusing