This is an interesting stuff even though it is very simple. Assume we have to retrieve recent 7 days items from a sharepoint list. For this purpose obviously we need to use CAML query (static query, not dynamic) . You can use the following code snippet for the reference.
Assume you have got SPSite object and continue with the following snippet.
SPList list = site.RootWeb.Lists["PradeepaStats"];
SPQuery query = new SPQuery();
query.Query = "<Where><Eq><FieldRef Name='TaskDueDate' /><Value IncludeTimeValue='TRUE' Type='DateTime'>[Today-7Day(s)]</Value></Eq></Where>";
SPListItemCollection items = list.GetItems(query);
Hope this may help someone
Cheers
Assume you have got SPSite object and continue with the following snippet.
SPList list = site.RootWeb.Lists["PradeepaStats"];
SPQuery query = new SPQuery();
query.Query = "<Where><Eq><FieldRef Name='TaskDueDate' /><Value IncludeTimeValue='TRUE' Type='DateTime'>[Today-7Day(s)]</Value></Eq></Where>";
SPListItemCollection items = list.GetItems(query);
Hope this may help someone
Cheers
Pradeepa achar
Comments