Filtering dates

hello friends i’m new in uipath studio and i have atask… i have excel sheet that have dates …i want to filter them if the dates >2020 then write it to the another excelsheet how can i filter the date??

Welcome to the UiPath Community @Ahmad_Samen!

create a datatable using Build Datatable Activity and ads all the columns of your input file in that, give a variable to that Build Datatable, say dtFilteredResult

You can read the excel using Read Range activity, and store the output in a variable, say dtInput

then use aFor each data row activity to loop through the dtInput. This will have one row in one iteration.

For each data row will have a looping variable, mostly DataRow. You can check that in the left panel of for each data row loop.

In that loop, add a IF condition to check the value of that date, if that is satisfied then you can store it in the datatable, dtFilteredResult.
You can store using the Add Data Row activity and pass row value as, DataRow

Condition:

If that date is in a column named as, DateColumn

Datetime.ParseExact(DataRow("DateColumn").ToString,“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture) >= Datetime.ParseExact(“01/01/2020,“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

This is if the date in that column is in MM/dd/yyyy format

if it is in some other format, you can mention that. For eg.: dd/MM/yyyy

That code basically converts the string to date
and date is compared simply by using > operator

To use this code you need to install below namespace
System.Globalization

you can install the namespace by going to the namespace tab in the below panel, in the right of variable and argument.

Hope this helps! Happy Automating!

Hi,

Hope the following sample helps you.

dt.AsEnumerable.Where(Function(r) DateTime.Parse(r("DateColumn").ToString).Year>2020).CopyToDataTable()

Please check AddHeaders option in WriteRange activity.

Regards,

thank you very much
i have also one question please
how can i convert muslim/Hijri date to Gregorian date?