Here is my altered code after the comments:
The list contains about 3 items that have been created since Sunday with a CreateDate field of 26/02/2014
<script type="text/javascript" src="/scripts/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="/scripts/jquery.SPServices-2014.01.min.js"></script>
<script language="JavaScript">
$(document).ready()
var itemCount;
var daysFromSunday = (new Date()).getDay(),
dateOffset = (
daysFromSunday > 0 ? " OffsetDays='-" + daysFromSunday + "'" : ""
),
query;
var daysToSunday = 7 - daysFromSunday;
alert(daysFromSunday);
alert(daysToSunday);
var query = "<Query>" +
"<Where>" +
"<And>" +
"<Geq>" +
"<FieldRef Name='CreateDate' />" +
"<Value Type='DateTime'>" +
"<Today OffsetDays='-" + daysFromSunday + "'/>" +
"</Value>" +
"</Geq>" +
"<Leq>" +
"<FieldRef Name='CreateDate' />" +
"<Value Type='DateTime'>" +
"<Today OffsetDays='" + daysToSunday + "'/>" +
"</Value>" +
"</Leq>" +
"</And>" +
"</Where>" +
"</Query>";
alert(query);
$().SPServices({
operation: "GetListItems",
listName: "Opportunities",
async: false,
completefunc: function(xData, Status) {
itemCount = $(xData.responseXML).SPFilterNode("rs:data").attr("ItemCount");
}
});
alert(itemCount);
</script>
I put the alerts in and get sensible returns for days to and from sunday but on the alert for query it returns the whole code not a value. The last alert then returns the total amount of items in the list.The list contains about 3 items that have been created since Sunday with a CreateDate field of 26/02/2014