Excel dates are read in mixed formats ,so convert the value explicitly using DateTime.ParseExact with patterns (d/M/yyyy, dd/MM/yyyy) before comparing with Date.Today.
You want to compare this in excel in new column or are you processing after reading as datatable. Will help accordingly.
Try this
orderDateDT (DateTime)
Assign this
orderDateDT = DateTime.ParseExact(
CurrentRow(“orderdate”).ToString.Trim,
“dd/MM/yyyy”,
System.Globalization.CultureInfo.InvariantCulture
)
Then use if activity
orderDateDT.Date = DateTime.Today
This issue can be resolved by using linq function please find below :
Use assign activity inside
countToday = dtExcel.AsEnumerable().
Count(Function(r) DateTime.FromOADate(CDbl(r(“Excelcolumnname”))).Date = Now.Date)
Under For each row- use assign activity- orderdate = If(TypeOf row(“orderdate”) Is DateTime, CType(row(“orderdate”), DateTime).Date, DateTime.ParseExact(row(“orderdate”).ToString, {“dd/MM/yyyy”,“d/M/yyyy”,“dd-MM-yyyy”,“d-M-yyyy”}, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None).Date)
Then you can cross check via writeline-
If(orderDate < todayDate,
"Past: " & row(“Activity ID”).ToString(),
If(orderDate = todayDate,
"Today: " & row(“Activity ID”).ToString(),
"Future: " & row(“Activity ID”).ToString()
)
)
If helpful, mark as solution. Happy automation with UiPath
=> Read Range Workbook. Make Use Display format as True
Output → dt
=> Use below syntax to get Past Count and Future count PastCount = dt.AsEnumerable().Where(Function(x) If(TypeOf x("orderdate") Is Date, DirectCast(x("orderdate"), Date).Date, DateTime.Parse(x("orderdate").ToString(), System.Globalization.CultureInfo.CreateSpecificCulture("en-GB"), System.Globalization.DateTimeStyles.AssumeLocal).Date) < DateTime.Today).Count()
PastCount and FutureCount is of DataType System.Int32
If you want Past Count and Future Count in a single syntax use the below one: rowCount = "Past Count: " + dt.AsEnumerable().Where(Function(x) If(TypeOf x("orderdate") Is Date, DirectCast(x("orderdate"), Date).Date, DateTime.Parse(x("orderdate").ToString(), System.Globalization.CultureInfo.CreateSpecificCulture("en-GB"), System.Globalization.DateTimeStyles.AssumeLocal).Date) < DateTime.Today).Count().ToString() + "| Future Count: " + dt.AsEnumerable().Where(Function(x) If(TypeOf x("orderdate") Is Date, DirectCast(x("orderdate"), Date).Date, DateTime.Parse(x("orderdate").ToString(), System.Globalization.CultureInfo.CreateSpecificCulture("en-GB"), System.Globalization.DateTimeStyles.AssumeLocal).Date) > DateTime.Today).Count().ToString()
rowCount is of DataType System.String
Please find the below workflow for better understanding: Test (1).xaml (13.3 KB)