1

I am trying to take the count of records in a list within a date period. my query render like this

  var qry = "<Where><And><Geq><FieldRef Name='Requested_x0020_Date' /><Value  Type='DateTime'>" + weekDates["start"].toString() +
                "</Value></Geq><Leq><FieldRef Name='Requested_x0020_Date' /><Value Type='DateTime'>" + weekDates["end"].toString() +
                "</Value></Leq></And></Where>";

 weekDates["start"]="dd/MM/yyyy" .

my function is 
 $().SPServices({
                operation: "GetListItems",
                async: false,
                listName: "Service Requests",
                CAMLQuery: qry,
                CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
                completefunc: weeklyCount
            });

It gives zero count and an error in console http://devappsrv2/EN/HelpDesk/_vti_bin/Lists.asmx 500 (Internal Server Error)

Please help me. thanks

  • <Where><And><Geq><FieldRef Name='Requested_x0020_Date' /><Value Type='DateTime'>" + weekDates["start"].toString() + "</Value></Geq><Leq><FieldRef Name='Requested_x0020_Date' /><Value Type='DateTime'>" + weekDates["end"].toString() + "</Value></Leq></And></Where> – Nidhin Nov 23 '17 at 5:54
0

Check you are using SharePoint datetime format "yyyy-MM-ddThh:mm:ssZ" for querying date(weekDates variable).
Also add IncludeTimeValue='TRUE' with value type in the caml query.

var qry = "<Where>"+
        "<And>"+
            "<Geq><FieldRef Name='Requested_x0020_Date' /><Value IncludeTimeValue='TRUE' Type='DateTime'>" + weekDates["start"].toString() +"</Value></Geq>"+
            "<Leq><FieldRef Name='Requested_x0020_Date' /><Value IncludeTimeValue='TRUE' Type='DateTime'>" + weekDates["end"].toString() +"</Value></Leq>"+
        "</And>"+
    "</Where>";

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.