Hi all,
I am facing with an issue with filter data table.
I have an excel with column name as Expiry Date, in that column I have past date, present date and future dates.
I need to get present and future dates only.
In the filter data table I have given “Expiry Date”>=Today
But this logic is not working.
Please help me.
Thanks in advance
Lak_Ui
(Lakshmi)
March 1, 2024, 5:20am
2
May be the format of the date you are passing might be differnt in the excel and whetever you are passing in the filter condition
Date format is dd-MM-yyyy
mkankatala
(Mahesh Kankatala)
March 1, 2024, 5:23am
4
Hi @amitha.aenugula
Try this linq query:
filteredDataTable = yourDataTable.AsEnumerable().Where(Function(row) DateTime.ParseExact(row("Expiry Date").ToString(),"dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture) >= DateTime.Today).CopyToDataTable()
After enabling Preserve Format, if you get the date format as dd-MM-yyyy the above query will work, or specify the format so that I can help you with updated query.
Hope it helps!!
Hi @amitha.aenugula
Assign activity:
To: filteredDataTable
Value: dt.AsEnumerable().Where(Function(row) DateTime.Parse(row("Expiry Date").ToString()) >= DateTime.Today).CopyToDataTable()
rlgandu
(Rajyalakshmi Gandu)
March 1, 2024, 5:27am
6
@amitha.aenugula
Enable preserve format in Read Range workbook, if you are excel process scope then use property Read Formatting try different options.
Note:Make sure the Formats of Expiry Date and Today have same Formats ,“dd/MM/yyyy” or anything this two variables will contain only one format
@mkankatala Thank you I got it
1 Like
mkankatala
(Mahesh Kankatala)
March 1, 2024, 5:35am
8
It’s my pleasure @amitha.aenugula
Happy Automation!!
system
(system)
Closed
March 4, 2024, 5:36am
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.