How to filter the hours in datatable?

I have attached my Datatable here.

I need to filter the datatable based on the Hours greater than 09:01 only
I have used filter datatable activity for this scenario but I don’t know where I am doing the mistake.System1_FilterHoursBasedOnCondition.xaml (7.2 KB)
Can anyone help me for this?


The problem with this scenario and the Filter DataTable activity is that operations like bigger than (">") are meant to be used with integers and maybe DateTimes.

Your operation is “Hours” > “09:01” - it resembles a TimeSpan (usually: “hh:mm:ss”).

I don’t know if or how you can use the Filter DataTable activity for this issue, but you can try to convert your String (“09:01”) to TimeSpan first (Possible To Convert String written "xx:yy:zz" To TimeSpan "hh:mm:ss"?), then check if the timespan is longer than your constant like this:
TimeSpan.TotalMinutes > (9*60+1) - Forum thread for reference

@Palaniyappan @KarthikByggari @ClaytonM - do you guys know how to solve this more elegantly?

Cheers, Lukas

1 Like

you have that field as string so a filter like this would not make a lot of sense, you are better off using an IF condition inside a For Each…

1 Like

As @lukasziebold mentioned, you just need to convert your string to a numerical or timespan value.

Check this out on how to parse the string as a timespan:

I’m also not convinced the Filter Data Table works well with non-string values. If that is the case, then you would need to use select or linq:
dt1.AsEnumerable.Where(Function(r) TimeSpan.Parse(If(TimeSpan.TryParse(r("Hours").ToString.Trim), r("Hours").ToString.Trim, "00:00")) > TimeSpan.Parse(hoursMin) ).ToArray

hoursMin would equal “09:01”



System1_FilterHoursBasedOnCondition.xaml (11.2 KB)
I am getting stuck in this. Can you guide me the flow please?

Thanks for your support.
I have tried this one but getting error.

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