How to find latest time

@khooshbu.jani

Firstly i asked you add hh:mm:ss tt inplace of hh:mm:ss in sorting…

Please try thesame…

Else if you want to go with one columns then

We can do that also but I observed the times are differnet in date/time and the time column is that fine?

If yes then we can remove mt completely and use md only for time also directly in the add row

Cheers

yes we can remove time column that will work

@khooshbu.jani

Try this

(From row In dtInput Group By id=row(0) Into grp = Group Let md=grp.Max(Function (d) d(1)) Let mt = grp.Max(Function(x) Cdate(If(x(1).ToString.Trim.Equals(String.Empty),"12/30/1899 ",CDate(x(1).Tostring).ToString("MM/dd/yyyy ")) + If(x(2).ToString.Trim.Equals(String.Empty),"00:00:00 AM",Cdate(x(2).Tostring).ToString("hh:mm:ss tt")))) Select dtMax.Rows.Add({id,If(md.ToString.Trim.Equals(String.Empty),"",CDate(md.Tostring).ToString("MM/dd/yyyy")),cdate(mt).ToString("hh:mm tt")})).CopyToDataTable

image

cheers

Got the output Greatly thankful to you.

And if I am taking the value from logindate/time column only then do i have to remove whole mt part?

@khooshbu.jani

Yes you can remove mt part and in the add part use x(1) itself for the time also

Please mark the appropriate solution so that it helps others

cheers

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.