How to Filter Column based on Current Date For Specified Range of Time

We want to Filter a DataTable with Column having Name “Instruction Date Time” with all data in Range of date that is"27/01/2021 17:00:00" to"27/01/2021 17:30:00" and remove data which contains time before “17:00:00”. and Time after “17:30:00”

Kindly suggest us the logical flow for same.

Filter data table activity could be used

DATATABLE.Select(“[DateColoumName] >= #”+PeriodInit.ToString +“# AND [DateColoumName] <= #”+PeriodEnd.ToString+“#”).CopyToDataTable

var PeriodInit = 27/01/2021 17:00:00
var PeriodEnd 27/01/2021 17:30:00

Change the variable accordingly

Hi @Ripusudan_Sharma u can use below linq query

dt1.AsEnumerable().Where(Function (row) row(“Instruction Date Time”).ToString>“27/01/2021 17:00:00” And
row(“Instruction Date Time”).ToString<“27/01/2021 17:30:00”). CopyToDataTable

Try this

Mark it as solution if it resolves ur query

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

1 Like

Assign: Cannot perform ‘<=’ operation on System.String and System.DateTime.

Facing this issue while using this Query

Hi @Ripusudan_Sharma
Check this workflow
process1.zip (603.0 KB)

I done the same code and works fine for me

Sample excel fil is also attached in the zip file

Regards

Nived N

Happy Automation

1 Like