Query Sharepoint WSS 3 calendar list using EventDate

Jan 31, 2011 at 8:03 PM

I am trying to limit the list items returned from my Sharepoint WSS 3 calendar list.  When I run the following, everything works and I see every event in the calendar list.  I am using SPServices 0.5.8 within IE7.

<script type="text/javascript" src="jquery/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="SPServices/jquery.SPServices.min.js"></script>
<script language="javascript" type="text/javascript">

$(document).ready(function() {
  $().SPServices({
    operation: "GetListItems",
    webURL: "mySiteURL",
    async: false,
    listName: "myListID",
    viewName: "myListViewID", CAMLRowLimit: 0, completefunc: function (xData, Status) {
      $(xData.responseXML).find("[nodeName=z:row]").each(function() {
        var liHtml = "<li>" + $(this).attr("ows_EventDate") + ", " + $(this).attr("ows_Title") + "</li>";
        $("#tasksUL").append(liHtml);
      });
    }
  });
});
</script>
<ul id="tasksUL"/>

When I add query information as shown below, no list items are returned even though there are items with EventDate >= 2011-01-31 00:00:00.  Please help me see what I am doing wrong with this query.

<script type="text/javascript" src="jquery/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="SPServices/jquery.SPServices.min.js"></script>
<script language="javascript" type="text/javascript">

$(document).ready(function() {
  $().SPServices({
    operation: "GetListItems",
    webURL: "myListURL",
    async: false,
    listName: "myListID",
    viewName: "myViewID",
    CAMLQuery: "<Query><Where><Ge><FieldRef Name='EventDate' /><Value Type='DateTime'>2011-01-31T00:00:00Z</Value></Ge></Where></Query>",
    CAMLQueryOptions: "<QueryOptions><DateInUtc>TRUE</DateInUtc></QueryOptions>",
    CAMLRowLimit: 0,
    completefunc: function (xData, Status) {
      $(xData.responseXML).find("[nodeName=z:row]").each(function() {
        var liHtml = "<li>" + $(this).attr("ows_EventDate") + ", " + $(this).attr("ows_Title") + "</li>";
        $("#tasksUL").append(liHtml);
      });
    }
  });
});
</script>
<ul id="tasksUL"/>

 

 

Thanks,

Jan 31, 2011 at 8:15 PM

SOLVED:

Never mind.  Sorry for the clutter on the discussion.  Turns out I had the wrong text for the >= operator.  I had "Ge" and it should have been "Geq."  After making that change. it works as intended.

Coordinator
Feb 1, 2011 at 12:14 AM
Sam: Nice to see you worked it out. Don't hesitate to use these forums at all. Sometimes framing the question here is enough to lead to a solution. M.