c# - Group by date using datatable -


I have a problem while grouping my dataset,

Here is the data,

And I based on this time, Place I want to combine in the end time and duration.

 Date start time expiration duration Duration 23/07/2014 10:30 12:30 2 hours 00 min near the highway 24/07/2014 01:00 01:30 01:30 0 hours 30 minutes From Texas 

Please help me get this solution Thanks in advance.

I think this should work:

  DataTable DT = New datatable (); Dt.Column.AddRange (New DataColumn [] {New Data Columns ("Date", Type Time), New Data Column ("Location", Typef (String)}}; Dt.Rows.Add (DateTime.ParseExact ("23/07/2014 10:30", "dd / MM / yyyy HH: mm", New CultureInfo ("fr-fr"), "near the highway"; Dt.Rows.Add (DateTime.ParseExact ( "23/07/2014 11:30", "dd / MM / yyyy HH: mm", new cultureinfo ("fr-fr"), "near the highway"); dt.rows.Add (DateTime.ParseExact ( "23/07/2014 12:30", "dd / MM / yyyy HH: mm", New CultureInfo ("fr-fr"), "near the highway"; Dt.Rows.Add (DateTime.ParseExact (" 24/07/2014 01:00 "," dd / MM / yyyy HH: mm ", New CultureInfo (" fr-fr ")," Tex From "" Dt.Rows.Add (DateTime.ParseExact ("24/07/2014 01:10", "dd / MM / yyyy HH: mm", New CultureInfo ("fr-fr"), "From Texas "; Dt.Rows.Add (DateTime.ParseExact (" 24/07/2014 01:20 "," dd / MM / yyyy HH: mm ", New CultureInfo (" fr-fr ")," From Texas "; Dt.Rows.Add (DateTime.ParseExact ("24/07/2014 01:30", "dd / MM / yyyy HH: mm", New CultureInfo ("fr-fr"), "From Texas"; Datatelle dt2 = new datatile (); New data columns [] (new data columns [] (new data columns ("date"), new data columns ("start time"), new data columns ("end time"), new data columns ("period"), New group of data ("location")}); Var group = dt.AsEnumerable () .groupb (line = & gt; line ["location"]); foreign (different groups in groups) {Console.WriteLine (group.Key ); Var group = 2 = group.orderbie (line = & gt; line ["date"]). Group (line = & gt; convert.tadetetime (line ["date"]) .Testring ("DD / MM / Yay "); F Oreach (2 groups in groups 2) {Console.WriteLine ("\ t" + group2.Key); Var list = group2.ToList (); Var startDate = Convert. ToDateTime (list [0] ["Date"]); Var endDate = Convert.ToDateTime (list [list1] ["date"]); timspan ts = end-date-date; dt2.rows.Add (group2.key, startDate.ToString ("HH: mm" ), EndDate.ToString ("HH: mm"), T. hours + "hours" + T. min + "minutes", group key);}}  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -