SharePoint REST API

Narayana 21 Reputation points
2021-04-28T09:03:50.45+00:00

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.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,202 questions
0 comments No comments
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,001 Reputation points
    2021-04-29T01:41:28.15+00:00

    Hi @Narayana ,

    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.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Narayana 21 Reputation points
    2021-04-29T04:41:23.49+00:00

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

    0 comments No comments