Filter Current date and time (MM/DD/yyyy hh:mm)

Hi everyone,

I have an excel sheet with the following data:

I want to read these data to the datatable and filter for rows based on date/time column if they are matched to the system date time currently:

I have tried the following filter but it doesn’t work:

What you see in Excel isn’t necessarily what you get in your datatable. After your Read Range set a breakpoint and look at the data in the datatable to see the exact values.

Also, every time you run what you have the Datetime.Now.ToString(“MM/dd/yyyy HH:mm”) will be different. It seems unlikely you’d get a match down to the minute.

What is your goal here, what are you trying to achieve?

refer to the first part where analysis options are described:

Hi @josiahgoh276

If your Date/Time column has 00 as seconds for all rows and the seconds no matters for your filter, you can try this in value field in Filter Data Table

new DateTime(Now.Year, Now.Month, Now.Day, Now.Hour, Now.Minute, 00)

If seconds in your rows are diffrent than 00 but it no matter for your filter, you can try this:

one thing to notice, your expression always return false even if seconds matchs because you are trying to compare different data types (System.DateTime with System.String)


I am trying to run an automation to remove records in datatable, which is not matched to the current date/time for data engineering purposes


Try this in assign

Dt = dt.AsEnumerable.Where(function(x) Cdate(x("ColumnName").ToString("MM/dd/yyyy HH:mm)).Equals(Now.ToString("MM/dd/yyyy HH:mm))).CopyToDataTable

But again matching to minutes mught not be a good idea

Also to avoid situation like no match use if condition with above expression and at end use .Count >0 instead of .copytodatatable


Will you recommend matching to hours? Will it be possible for you to create a process for me to reference?

This doesn’t work for me, do you have a process which i can follow?

I thought i have converted it into a string in my formulas


Just remove :mm from the above code


Can you explain more about the formula? I don’t really get how it works with my excel sheet

Hi ppr, i don’t really understand this. Can you share more information?


Dt is a datatable into which the data is read from excel using read range

Where is for filtering in linq

Inside that I am converting the The required date column to the give format and comparing with the current time in same format


Hi, set breakpoint after read range activity and check the output of read range, date is in correct format or read in another format in local or Immediate panel.


it was told to you, that we check always the data table and not the excel for details
in this FirstAid it introduced on how to use the immediate panel for analyses

When LINQ is new, have a look here:
[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum

Coming back to your case:

now is:

But Now is constantly changing and it will be less realistic, that exactly (today: 13 Dez 17:29) the bot will run. (Was also told to you by others)

When doing the filtering on todays date we would refer to todays date like:
And filtering against the parsed date info from the datatable (showing different conversion options) by same approach of refering to the date

The comparison will be done on DateTime data type level

Rough sample: