sheik JAMEEL
sheik JAMEEL

Reputation: 13

Get today's items from sharepoint list

i'm trying to get today's items from a sharepoint list as below: however returning with empty.

        SPSite site = new SPSite(url of site);
        SPWeb web = site.OpenWeb();           
        SPList olst = web.Lists[ListName];           
        SPQuery oqry = new SPQuery();

        qryAdminTick.Query = "<Where><Eq><FieldRef Name='Created' /><Value IncludeTimeValue='FALSE' Type='DateTime'>" + DateTime.Now.ToString("yyyy-MM-dd") +"</Value></Eq></Where><OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy>";
        SPListItemCollection itemColl = olst.GetItems(oqry);

Thanks in advance.

Upvotes: 0

Views: 187

Answers (1)

Thejaswy
Thejaswy

Reputation: 301

you are assigning the query to wrong variable, it should be oqry.Query instead of qryAdminTick.Query and your code should work fine.

Upvotes: 1

Related Questions