This project has moved. For the latest updates, please go here.

Date Filter is not working

May 20, 2015 at 9:24 PM
I am using the following CAML query and the SP Services does not return any values. Any help on this is appreciated...

"<Query><Where><Geq><FieldRef Name='ProjectStartDate' /><Value IncludeTimeValue='True' Type='DateTime'>2015-01-01T00:00:00Z</Value></Geq><OrderBy><FieldRef Name='ProjectStartDate'/></OrderBy></Where></Query>"
May 20, 2015 at 9:36 PM
Edited May 20, 2015 at 9:37 PM
It's hard to know what the actual problem is. Are you getting a valid response from the server indicating ItemCount is zero or are you getting an error? Try running your code with the CAMLQuery above commented out to make sure that everything else is valid.

May 21, 2015 at 12:45 AM
Hi Marc, Thanks for the quick reply. I've commented the CAML, still the values are not showing up. Below is the code used. I am getting 0 result always.

var currYear = new Date().getFullYear();
var currMonth = new Date().getMonth();

var initiatedProjFilterQuery = "<Query>" +
                                "<Where>" +
                                     "<Geq><FieldRef Name='ProjectStartDate' /><Value IncludeTimeValue='False' Type='DateTime'>" + currYear + "-01-01T00:00:00Z</Value></Geq>" +
                                "<OrderBy><FieldRef Name='ProjectStartYear'/></OrderBy></Where>" +

var projectsYTD = {};
var projectsMonth = {};
var total = 0;
    operation: "GetListItems",
    webURL: "/sites/CITraining/",
    listName: "CI Training Projects",
    async: false,
    CAMLQuery: initiatedProjFilterQuery,
    CAMLViewFields: "<ViewFields><FieldRef Name='Region' /><FieldRef Name='ProjectStartDate' /></ViewFields>",
    completefunc: function (xData, Status) {
        if ($($(xData.responseXML).SPFilterNode("errorstring")).text() != "") {
            var error = $($(xData.responseXML).SPFilterNode("errorstring")).text();

        jQuery(xData.responseXML).SPFilterNode("z:row").each(function () {
            var node = jQuery(this);
            var region = node.attr("ows_Region");
            if (projectsYTD[region] == undefined) {
                projectsYTD[region] = 1;
            } else {
                projectsYTD[region] += 1;

            var month = node.attr("ows_ProjectStartDate").substr(5, 2);

            if (currMonth == Number(month)) {
                if (projectsMonth[region] == undefined) {
                    projectsMonth[region] = 1;
                } else {
                    projectsMonth[region] += 1;

        total = jQuery(xData.responseXML).SPFilterNode("z:row").length;
May 21, 2015 at 1:36 AM
Hi Marc, I've reviewed the code with fiddler and I see http 400 error behind the scene.. please let me know your thoughts to fix this.
May 21, 2015 at 1:29 PM
Pare it all the way down to the most basic query and look at the response to make sure it's valid. Then build things up again. It could be something as basic as your webURL being incorrect. In other words, you may be working on the wrong problem.