I'm trying to perform a query on the Office 365 Graph API to say "give me all emails before {someISODateTimeString}"
For example:
https://graph.microsoft.com/v1.0/me/messages?$filter=receivedDateTime gt 2016-02-26T14:41:08Z
It would seem that gt (greater than) is actually operating as greater than or equal to (ge), as the above query returns me an email which has the exact receivedDateTime value that I passed into the query.
So I tried a workaround:
https://graph.microsoft.com/v1.0/me/messages?$filter=receivedDateTime ne 2016-02-26T14:41:08Z AND receivedDateTime ge 2016-02-26T14:41:08Z
This also fails to omit the email with the received date of 2016-02-26T14:41:08Z.
Any help with how to achieve a "greater than" query on received date would be appreciated.
The behavior you're seeing is actually due to a loss in precision in the REST APIs. Most date fields (including receivedDateTime) are actually stored with more precision than second. What's happening currently is that your request is being translated to a query where the receivedDateTime > 14:41:08.0000. Messages that appeared at 14:41:08.01 are technically greater than that, even though the precision is lopped off making it appear equal.
The work-around you can use (and one we are internally also looking to apply in all "gt" or "lt" scenarios) is to use "ge" for the next unit, so in your example:
https://graph.microsoft.com/v1.0/me/messages?$filter=receivedDateTime ge 2016-02-26T14:41:09Z
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With