Filters date that are later than today

Hello, I would like the robot to filter a column in Excel by dates, so that it only filters dates that are later than today. How can I do this?

Hey @sullivanne
you can try to use:
filteredDt = dtExcelData.AsEnumerable().Where(Function(row) Not String.IsNullOrEmpty(row("YourDateColumnName").ToString) AndAlso DateTime.Parse(row("YourDateColumnName").ToString) > DateTime.Now).CopyToDataTable()

Hi @sullivanne

Can you try the below

filteredDataTable = yourDataTable.AsEnumerable().Where(Function(row) DateTime.Parse(row.Field(Of String)("DateColumn")) > DateTime.Today).CopyToDataTable()

Cheers!!

Hi @sullivanne

Try the below syntax:

YourDataTable = YourDataTable.AsEnumerable().Where(Function(row) DateTime.ParseExact(row("YourDateColumn").ToString(), "dd.MM.yyyy", CultureInfo.InvariantCulture) > DateTime.Now).CopyToDataTable()

Regards

@sullivanne

(From row In yourDataTableVar.AsEnumerable()
Where DateTime.Parse(row("YourDateColumnName").ToString()) > DateTime.Today
Select row).CopyToDataTable()

Hi @sullivanne

If the target column is already in date format you can use Read Range Workbook Activity and use Filter Data Table Activity


Thank you for your help, I don’t know if that’s what you meant. I’m new to UiPath. I get an error :frowning: I don’t know where to enter this and how to open it in Excel later.

@sullivanne

Can you show the error please

May be there are no dates that arw after the todays date

Cheers

May i ask can we type the cell no. ie E of the row?

Actually i am a new comer, May i ask how i should type in ie () this code? Although i still not yet faced this problem, i want to learn in advance

Thank You

@Happydayyy

As per error looks like the left side variable type in string …please check and change to datatable

Cheers

@sullivanne
You shouldn’t get any errors:


Please check if your variable is datatble type (datetype->advanced options->datatable):

NewBlankTask25.zip (52.5 KB)