Date Time Format change and comparison

I have date in “dd/MM/yyyy hh:mm:ss” in Excel file. I have to filter the data of old dates from today.

date1=DateTime.ParseExact(date1,“dd/MM/yyyy hh:mm:ss”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)


Please try this

HI @ankush.jeengar

How about this expression?

DtBuild.AsEnumerable.Where(Function(x) Not(String.IsNullOrWhiteSpace(x("Excel date").ToString)) AndAlso (CDate(x("Excel date").ToString)<(new DateTime(Now.Year,Now.Month,Now.Day, Now.Hour, Now.Minute, Now.Second)))).ToArray.copytodatatable

Check out the XAML file

OldDateFromCurrentDate.xaml (7.6 KB)



getting this error

Use Read range activity Instead of Build data Table. Or share sample excel file here @ankush.jeengar

find a firstAid for checking date within a datatable populated from an excel read range

Hello @ankush.jeengar
Please check the below video. Here the first thing is the conversion of string to datetime, then do the substraction.


Hi @ankush.jeengar ,

Could you maybe also try with the below Expression :

FilteredDT = DT.AsEnumerable.Where(Function(x) DateTime.ParseExact(x("Your Date Column").ToString,"dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture).Date < Now.Date).CopyToDatatable

Here, DT is the Input datatable read from Excel sheet, FilteredDT is the Output Datatable after filtering.

Also for handling the error on direct CopyToDatatable, refer the post below :

Let us know if you are still facing issues.

Thanks SuperMan @supermanPunch

1 Like

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