I'm going to help you get started by showing you how to use Linq to create a collection of DataRows organized by UserID:
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
var userIDGroups = dt.Rows.Cast<datarow>()
.GroupBy(row => row[1])
.Select(grp => grp.ToList()).ToList();
foreach (var grp in userIDGroups)
{
Console.WriteLine("UserID: {0}", grp[0].ItemArray[1]);
foreach (var row in grp)
{
Console.WriteLine("Date: {0}", row.ItemArray[2]);
}
}
This code:
a. converts the DataRowCollecton to an IEnumerable so we can use Linq on it.
b. then it uses 'GroupBy to get a set of 'Groups (IEnumerables of Rows ... a 'LookUp object, actually), selected by the 'UserID field ... field #2 in the Row
c. then we select each group/LookUp, and turn it into a List of DataRows
d. finally, we turn this IEnumerable of Lists of DataRows into a List.
The result of executing this on your DataTable will look like this:
UserID: 1
Date: 2/6/2016 8:12:00 AM
Date: 2/6/2016 3:43:00 PM
Date: 2/6/2016 3:45:00 PM
UserID: 2
Date: 2/6/2016 8:20:00 AM
Date: 2/6/2016 3:43:00 PM
UserID: 3
Date: 2/6/2016 8:30:00 AM
If you study this code carefully you can see how you can access any field in the rows organized by UserId; you can then get the Min and Max Dates in each group and calculate time-elapsed, etc.