I want to retrieve items from list which are lessthan seven days from today date.
seven days means: 12/21/2015.
Using caml query. can anybody know please tell me.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.Sign up to join this community
In a caml query, you will need to use
<Today> token with
<Where><Leq><FieldRef Name='Your_Date_Column' /><Value Type='DateTime'><Today OffsetDays='7' /></Value></Leq></Where>
Reference: Using the Today token in a CAML query
Let SharePoint do the work for you
You can Filter by date in the View Filter settings,
This shows the Items created in the Last Week:
You can use spaces (and linebreaks) in a Calculated Column Formula,
but do NOT use spaces in this Filter Formula
If you do, you get the most informative message:
Use following code if using jquery:
var lastWeek = new Date(); lastWeek.setDate(lastWeek.getDate() + 7);
now you can use this variable the way you want. I hope this is what you were in need
objQuery.Query = "<Query><Where><And><Geq><FieldRef Name='EventDate' /><Value IncludeTimeValue='TRUE' Type='DateTime'><Today OffsetDays='7' /></Value></Geq><IsNotNull><FieldRef Name='Title' /></IsNotNull></And></Where><OrderBy><FieldRef Name='EventDate' Ascending='True' /> </OrderBy></Query>";