I need to filter data two times, once using current user and then by date. So I have used below rest API..

 url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('LateLogin')/items?$select=Author/Title,Duration,Date,Created&$expand=Author&$filter=Author/Title eq 'Vikash Kumar'&Created ge '2015-10-15' & Created le '2015-10-20'&@target='" + hostweburl + "'",

but it is filtering only current user records and not by date....

  • Really your accepted solution worked for you? I got error while running it? The expression "$filter=(Author/Title eq 'Vikash Kumar') and ((Created ge '2015-10-15') and (Created le '2015-10-20'))" is not valid. – Atish Dipongkor - MVP Oct 21 '15 at 13:00

Could you please try below line of code?

 url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('LateLogin')/items?$select=Author/Title,Duration,Date,Created&$expand=Author&$filter=(Author/Title eq 'Vikash Kumar') and ((Created ge '2015-10-15') and (Created le '2015-10-20'))&@target='" + hostweburl + "'",
  • Really? It worked? How? I am getting error while running this!!! – Atish Dipongkor - MVP Oct 21 '15 at 12:53
  • "$filter=(Author/Title eq 'Vikash Kumar') and ((Created ge '2015-10-15') and (Created le '2015-10-20'))" is not valid – Atish Dipongkor - MVP Oct 21 '15 at 13:02

There are two problems in your current URL

use and instead of & inside the $filter

Before using DateTime in $filter, you have to convert it into toISOString(). So do it like following

var startDate = new Date("2015-10-15");
var endDate = new Date("2015-10-20");

Now use above dates in your URL

url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('LateLogin')/items?$select=Author/Title,Duration,Date,Created&$expand=Author&$filter=Author/Title eq 'Vikash Kumar' and Created ge "+ startDate.toISOString() +" and Created le "+ endDate.toISOString() +"&@target='" + hostweburl + "'",

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.