Delete file in excel sort by date

I have an XLSX with many columns and i need to search the one with more than 31 days old and delete it from the Excel, the date have this format (YYYY-MM-DD). maybe LinQ do the trick usin Uipath, but it dosn’t work, how can i do this?

1 Like

Hi @panpan1020,

I believe that in your case you would have to bring the data into a datatable and then apply a filter based on the date column and prior to that you would need to convert the string into date and apply the filter later on.

Something like this:

myDt = myDt.Where(Function(x) 
(DateTime.Now - DateTime.ParseExact(x.Item("ColumnDate").ToString, "yyyy-MM-dd", CultureInfo.InvariantCulture)).Days > 31).ToDataTable
2 Likes

I supose that, i can make that code in an Assign Activity, right?

1 Like

Easier but longer way

  • Use For each row in ExtractedDatatable
  • If Convert.todatetime(row(“DateColumn”).tostring)>Today.addDays(31))
3 Likes

Read Range
Create a data table with the read
Put the for each row i supose right?

Yes you are correct…

1 Like

Can you make an Example .xaml Please?

This is what i got.Capture

See the attached.

test.xaml (7.6 KB)

2 Likes

You’re the best!!!

1 Like