Split date time from excel

Hi All ,
I have column in datatable where data is 08/11/2022 12:30:00 How to filter using date and take row where date is equal or greater than current date.

HI @tharani.natarajan

Check out the LINQ Expression

DTInput1.AsEnumerable.Where(Function(r) DateTime.Parse(r("Column Name").ToString)>=New DateTime(Now.Year, Now.Month, Now.Day, Now.Hour, Now.Minute, Now.Second)).CopyToDataTable

If possible can you share the sample input excel file?

Regards
Gokul

HI @tharani.natarajan

Checkout this expression

DtTest.AsEnumerable().Where(Function(d) DateTime.ParseExact(d("Column1").ToString,{"dd/MM/yyyy hh:mm:ss","MM/dd/yyyy hh:mm:ss"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None)>=DateTime.Now).CopyToDataTable

If your date in the datatable has different format you can add the other formats inside the {“”,“”}
Each format is a string and it is seperated by comma

Regards
Sudharsan

1 Like

Hello @tharani.natarajan
By using a filter data table you can filter the data
Kindly find the xaml file, you may get some idea.
Forum_DateFilter.zip (10.2 KB)


Input
image

Output

image

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