1

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

Convert the date at assignment instead of converting for display so it is properly queried on request

var dateAsObject = $(this).datepicker( 'getDate' ); //the getDate method
//convert time here on object based on your local timezone
dateAsObject = $.datepicker.formatDate('mm-dd-yy', new Date(dateAsObject))

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.