question

NarayanaReddy-1539 avatar image
0 Votes"
NarayanaReddy-1539 asked NarayanaReddy-1539 answered

SharePoint REST API

I have a requirement to display all the list items that fall under a particular year.
I have a start date column with date data type in a list. I have to search and filter all the list items whose start date falls under a particular year chosen. Please advise, how to put filter condition in a REST API that can retrieve all the list items based on year. Filtering condition is on a Start Date column. Thank you for your help and support.

office-sharepoint-online
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered

Hi @NarayanaReddy-1539,

In SharePoint, the dateTime column is in ISO format : YYYY-MM-DDThh:mm:ssZ . So you could filter on the Date column like the below. My column name is Date, and it will get all items in 2020 year.


 /_api/web/lists/getbytitle('TestList')/items?$filter=Date ge datetime'2020-01-01T00:00:00Z' and Date le datetime'2021-01-01T00:00:00Z'



If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

NarayanaReddy-1539 avatar image
0 Votes"
NarayanaReddy-1539 answered

Thank you so much Michael for your reply. It is really helpful for me.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.