Tuesday, July 26, 2016

How to filter SharePoint list Based in Date Time in SharePoint 2013 using REST/ODATA

REST queries are quiet familiar when you are working with SharePoint Apps and SharePoint development.

I have found quiet difficult to pass the Date Time parameter to REST and took few minutes to figure that out.

These are few example of REST queries which uses Created Column as a sample field.

Filter Greater than Date

http://<sharepointurl>/_api/web/lists/getbytitle('Pages')/items?$filter=Created gt dateTime'2017-03-03T00:00:00Z'

Filter Less than Date

http://<sharepointurl>/_api/web/lists/getbytitle('Pages')/items?$filter=Created lt dateTime'2017-03-03T00:00:00Z'

Filter Equal Date

http:// <sharepointurl>/_api/web/lists/getbytitle('Pages')/items?$filter=Created eq dateTime'2017-03-03T00:00:00Z'

Filter Between Dates

http:// <sharepointurl>/_api/web/lists/getbytitle('Pages')/items? $filter=( Created gt dateTime'2016-03-03T00:00:00Z' and Created lt dateTime'2017-03-03T00:00:00Z')

Post a Comment