0

I had written the below piece of REST API to filter the data for SharePoint DateTime Column , But I find no luck to execute

Also, When I use startswith for SinglelieText column it's working fine. But for DateTime Column I am unable to crack

Can any one please do let me know what's wrong in it..

url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('OrderDetails')/items?$filter=(startswith(OrderDate,'3'))",
  • So what you're really looking for is filtering a datetime column by month? Check this answer. – wjervis Jun 11 '18 at 12:39
0

startswith takes two parameters (string, string),

If you're trying to filter with date-time the items in specific month, you can use month() function

because /_api/web endpoint does not support OData Date Time functions , as a workaround you can use /_vti_bin/listdata.svc end point which supports these functions

/_vti_bin/listdata.svc/OrderDetails?$filter=month(OrderDate)  eq 3


The above will return all items with Orderdate in March ,
Similar to this you can use :

day() or year() functions.

hope this will be helpful, please try and let me know.

  • I tired it Saeed, But I find no luck with Month() function sytax – MSA Jun 11 '18 at 5:22
  • 1
    @MSA what happened when you tried? Did you get an error? Incorrect results? – wjervis Jun 11 '18 at 12:36
  • @MSA please check the updated answer – A.Saéed Jun 12 '18 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.