If I want to find the latest time if all dates are same then how to do that?
I do have linq query for finding max date, but looking for max time
(From row In dtInput
Group By id=row(0) Into grp = Group Let md=grp.Max(Function (d) d(1)) Select dtMax.Rows.Add({id,If(md.ToString.Trim.Equals(String.Empty),“”,CDate(md.Tostring).ToString(“MM/dd/yyyyy”))})).CopyToDataTable
(From row In dtInput Group By id=row(0) Into grp = Group Let md=grp.Max(Function (d) d(1)) mt = grp.Max(Function(x) Cdate(If(x(1).ToString.Trim.Equals(String.Empty),"01/01/1900",CDate(x(2).Tostring).ToString("MM/dd/yyyy")) + If(x(2).ToString.Trim.Equals(String.Empty),"00:00:00 AM",Date.ParseExact(x(2).Tostring,"hh:mm tt",System.Globalization.CultureInfo.InvariantCulture).ToString("hh:mm:ss tt")))) Select dtMax.Rows.Add({id,If(md.ToString.Trim.Equals(String.Empty),“”,CDate(md.Tostring).ToString("MM/dd/yyyyy")),cdate(mt).ToString("hh:mm tt")})).CopyToDataTable
Please change the time format if its different…hh:mm tt is what is the format for 11:12 AM
(From row In dtInput
Group By id=row(0) Into grp = Group
Let maxDateTime = grp.Max(Function(d) CDate(d(1).ToString.Trim & " " & d(2).ToString.Trim))
Select dtMax.Rows.Add({id, If(maxDateTime.ToString.Trim.Equals(String.Empty), “”, maxDateTime.ToString(“MM/dd/yyyyy hh:mm:ss tt”))})
).CopyToDataTable
(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),"01/01/1900",CDate(x(2).Tostring).ToString("MM/dd/yyyy")) + If(x(2).ToString.Trim.Equals(String.Empty),"00:00:00 AM",Date.ParseExact(x(2).Tostring,"hh:mm tt",System.Globalization.CultureInfo.InvariantCulture).ToString("hh:mm:ss tt")))) Select dtMax.Rows.Add({id,If(md.ToString.Trim.Equals(String.Empty),“”,CDate(md.Tostring).ToString("MM/dd/yyyyy")),cdate(mt).ToString("hh:mm tt")})).CopyToDataTable
(From d In dtInput.AsEnumerable
Group d By k=d(0).toString.Trim Into grp = Group
Let go = grp.OrderBy(Function (x) CDate(x(1).toString.Trim).Date).ThenBy(Function (y) CDate(y(2).ToString.Trim).TimeOfDay)
Select r = go.Last()).CopyToDataTable
This has the same error of
Assign: Expression Activity type ‘VisualBasicValue`1’ requires compilation in order to run. Please ensure that the workflow has been compiled
@ Anil
I typed “” but it is giving me conversion error: Assign Conversion from string “01/01/000112:12:15:00 PM” to type ‘Date’ is not valid.
For simplicity, i removed time column which was separate and formate cell with “3/4/2023 8:01:00 AM”
Again when I have date and time written, why it is taking in 01/01/000112:12:15:00?
It has to check against each user last date and time logged in.
I know it is taking long, but I try to refer UiPath Forum before putting here.
:
!:image|682x103:
Please check this modified as per the data provided
(From row In dt 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",Cdate(x(2).Tostring).ToString("hh:mm:ss")))) Select dt1.Rows.Add({id,If(md.ToString.Trim.Equals(String.Empty),"",CDate(md.Tostring).ToString("MM/dd/yyyyy")),cdate(mt).ToString("hh:mm tt")})).CopyToDataTable
blank rows are also grouped…can remove them using a filter datatable
Thank you for the help.
It is giving me error of dt and dt1 is either not declared or not in the current scope. I see dt is declared, still it gives me the error.
I changed dt and dt1 to dtmax. so now it is giving the source contains no datarows. I do have data, Also I checked with file path. It is opening the correct file.
No Anil, it still gives me the same error. I noticed yyyyy part and removed one y. After your instruction i add ss part and AM part. still not working. if this is too complicated can we use the Login Date/Time column, which has a format of 3/4/2023 8:01:00 AM for simplicity?