Filter all days to a specific date

Hi, I would like the robot in the datatable to filter all days to a specific date, e.g. filter all days from today until the end of September - format daty: 2024-09-30 (YYYY-MM-DD). Thank You :slight_smile:

Hi @sullivanne

Try this

filteredDT = dt.AsEnumerable().Where(Function(row) DateTime.Parse(row("DateColumn").ToString()) >= DateTime.Today AndAlso DateTime.Parse(row("DateColumn").ToString()) <= New DateTime(2024, 9, 30)).CopyToDataTable()

Regards,

1 Like

Hi @sullivanne

You can use the LINQ Expression to filter the data with the required condition,

- Assign -> Output_DT = DT.AsEnumerable.Where(Function(X) CDate(X("Columnname").ToString)>=DateTime.Now AndAlso CDate(X("Columnname").ToString)<=DateTime.Now.AddMonths(1).AddDays(-1)).CopyToDataTable()

Hope it helps!!

1 Like

give a try at

Assign Activity
endDate | DataType: DateTime = #09/30/2024#

Assign Activity
dtFiltered =

(From d in YourDataTableVar.AsEnumerable
Let dp = DateTime.ParseExact(d("yourColName").toString.Trim, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture).Date
Where dp >= Now.Date AndAlso dp <= endDate.Date
Select r =d).CopyToDataTable

Handling empty Results:
:ambulance: :sos: [FirstAid] Handling of The source contains no DataRows exception - News / Tutorials - UiPath Community Forum

Analysis when Parseformat is to adapt:
:ambulance: :sos: [FirstAid] Datatable: Debug & Analysis invalid DateTime Strings / String to DateTime Parsing Issues - News / Tutorials - UiPath Community Forum

2 Likes

Hie @sullivanne
use read range to read the data
use for each row to iterate to loop through
use assign activity and in the assign save that column value which hold the date data
after that you can add this query which convert your date in your desired result
1- step
your input date as example -


Activity you need –
image
to store the date column in variable
image
to convert date format in your desired format

Hope you get the point .and understand the concept

cheers Happy Automation

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.