Hi everyone,
I want to filter a excel column containing dates where we have to filter 6 months older dates in that column, suggest method to get it
Read the data with Read Range and use LINQ for this.
filteredDataTable = (From row In inputDataTable.AsEnumerable() Where DateTime.Parse(row("YourDateColumn").ToString()) < Now.AddMonths(-6) Select row).CopyToDataTable()
Hello @Gopi_Krishna1
You can read the Excel-file using the “Read Range Workbook” activity.
Then use “Filter Data Table” activity to filter the rows you want.
Now.AddMonths(-6)
Regards
Soren
Ok this is because your system time format and the column format not matching.
Let’s try this query.
filtereddatatable = (From row In inputDataTable.AsEnumerable() Where DateTime.ParseExact(row("YourDateColumn").ToString(), "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture)) < Now.AddMonths(-6) Select row).CopyToDataTable()
Please try this
filtereddatatable = inputDataTable.AsEnumerable.Where(function(x) If(String.IsNullOrEmpty(x("YourDateColumn").ToString.Trim),Now,DateTime.ParseExact(x("YourDateColumn").ToString,"dd.MM.yyyy",System.Globalization.CultureInfo.InvariantCulture)) < Now.AddMonths(-6)).CopyToDataTable
Also here assumption is date is in format of dd.MM.yyyy . if it is different then change it …you can check the datatable from locals panel to see the format
make sure you initialize this datatable filtereddatatable
cheers
Great @Anil_G it’s working fine, thanks for your help❤️