1

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.

1

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;
}  
0

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

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.