SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to filter a list using the REST service. The column im trying to filter is the default column "Modified". My problem is: I can get all itens created today, but not only the items created after noon. It seems like Sharepoint is ignoring the time factor of a datetime column and only comparing the date.

I tried to use the Hour() function but I get a 400 (bad request) error.

share|improve this question

SharePoint 2010 REST Interface expects the following format for the Date column:

/_vti_bin/listdata.svc/ListName?$filter=Modified gt datetime'YYYY-MM-DDT12:00:00Z'

JavaScript example

var listTitle = "Requests";
var minDate = getMinDate();
var endpointUrl = "/_vti_bin/listdata.svc/" + listTitle + "?$filter=Modified gt datetime'" + minDate.toISOString() + "'";
$.getJSON(endpointUrl, function(data) {
    $(data.d.results).each(function(i,item){
         console.log(item);
    });
});


function getMinDate()
{
    var d = new Date(); 
    d.setMonth(d.getMonth() - 1);
    d.setHours(12);
    d.setMinutes(0);
    d.setSeconds(0);
    d.setMilliseconds(0);
    return d;
}  
share|improve this answer
up vote 0 down vote accepted

Well it seems to be impossible, so i worked around and used the client object model... shame...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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