I am trying to find the max and min DateTime from a CSV import.
I have this to import data from temp DataTable :
var tsHead = from h in dt.AsEnumerable() select new { Index = h.Field<string>("INDEX"), TimeSheetCategory = h.Field<string>("FN"), Date = DdateConvert(h.Field<string>("Date")), EmployeeNo = h.Field<string>("EMPLOYEE"), Factory = h.Field<string>("FACTORY"), StartTime = DdateConvert(h.Field<string>("START_TIME")), //min FinishTime = DdateConvert(h.Field<string>("FINISH_TIME")), //max };
Which works great. Then I want to group the data and show the start time and end time, which is the minimum / maximum for the corresponding fields.
So far I have this:
var tsHeadg = from h in tsHead group h by h.Index into g
Given that g.Min and g.Max will give me the lowest and highest DateTime for each schedule (grouped by index)
This does not work, however ... What is the best way to find the highest and lowest DateTimes in a group?
source share