Get Distinct record from sharepoint list for specific time

using (SPSite objSite = new SPSite(“siteurl”))
{

using (SPWeb oWeb = objSite.OpenWeb())
{

SPList oList = oWeb.Lists[“test”];
SPQuery objspquery = new SPQuery();
objspquery.Query = string.Format(“{0}”, “09/16/2014”);

SPListItemCollection objcoll = oList.GetItems(objspquery);
DataTable dt = new DataTable();
dt = objcoll.GetDataTable();

// find the list of unique/distinct users who submitted the entries against the given period
DataView view = new DataView(dt);
DataTable distinctUsers = new DataTable();
distinctUsers = view.ToTable(true, “UsernName”);

//Number of users(distinct/unique) against the given period & Team.
DataView view1 = new DataView(dt);
DataTable distinctUsersTeam = new DataTable();
distinctUsersTeam = view.ToTable(true, “UsernName”, “TeamName”);

}

}

List :
TestTlist

Result1:
result1

Result 2:

result2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s