Prathamesh Doke
Prathamesh Doke

Reputation: 845

SharePoint list filter using dd-mm-yyyy format

I have been trying to fetch records that are created on a specific date eg. 18-09-2019

my url is : https://dimensiondata3.sharepoint.com/_api/web/lists/getbytitle('PrathameshDemo')/items?$filter=Created eq datetime('13-09-2019')

but i'm getting an error :

{
    "odata.error": {
        "code": "-1, Microsoft.SharePoint.SPException",
        "message": {
            "lang": "en-US",
            "value": "The query is not valid."
        }
    }
}

How to fetch this list for a specific date?

Upvotes: 1

Views: 914

Answers (1)

Michael Han
Michael Han

Reputation: 3655

The problem was the formatting of string value as a valid SharePoint datetime.

SharePoint expects the date to be in ISO 8601 format.You could use the toISOString() Method to get datetime with the ISO 8601 format.

For your requirements, you want to get the items created on the day 2019/09/13. Assuming you are using UTC standard time, modify the query as follows:

$filter=(Created ge datetime'2019-09-13T00:00:00Z')and (Created le datetime'2019-09-14T00:00:00Z')

Upvotes: 1

Related Questions