vendredi 23 janvier 2015

Datetime format when using $filter in ListData.svc



I'm using ListData.svc to retrieve items from a SharePoint 2013 calendar list. I have two jquery ui datepickers to select the date range. Values are read with the following:



var s = moment(jQuery('.datepicker:eq(0)').datepicker("getDate")).format("YYYY-MM-DD");
var t = moment(jQuery('.datepicker:eq(1)').datepicker("getDate")).format("YYYY-MM-DD");


My $filter is:



"(datetime'" + s + "' eq StartDate) or (datetime'" + s + "' eq EndDate) or" +
"(datetime'" + t + "' eq StartDate) or (datetime'" + t + "' eq EndDate) or " +
"((datetime'" + s + "' lt StartDate) and (datetime'" + t + "' gt EndDate)) or " +
"((datetime'" + s + "' gt StartDate) and (datetime'" + t + "' lt EndDate)) or " +
"((datetime'" + t + "' gt StartDate) and (datetime'" + t + "' lt EndDate)) or " +
"((datetime'" + s + "' gt StartDate) and (datetime'" + s + "' lt EndDate))";


I have problems with all-day events.


In particular, selecting a date range of [2014-01-21 -> 2014-01-31], an all-day event of January 20th is returned.


Same problem using:



var s = jQuery('.datepicker:eq(0)').datepicker("getDate").toISOString();
var t = jQuery('.datepicker:eq(1)').datepicker("getDate").toISOString();


I know that dates are returned in UTC and hence when displaying results I convert them properly and I get correct values printed. My problem is in the request. How to specify dates in the request so that events are correctly filtered (i.e. all-day event of January 20th is not returned with the above specified date range)?


Thank You.








0 commentaires:

Enregistrer un commentaire