Filtering dates using Filter Data table

Hi there,

In a column of a Data table there can be text, a date or an empty cell.
I would like to filter only the cells with a date in it.
image

How do I do it with using Filter Data table?
image

Many, many thanks in advance!

BJ

Hello,

Please see this thread:

Thanks!
Athira

Thanks!! However I want to use the Filter Data Table function.

try this

image

regards

I receive an error because timeVar is not declared…

time var is your time variable, the one which you want to filter

OKay, but I don’t want to filter a time variable. I want to filter al the dates and to text or empty cells

use the is not empty

image

Regards!

Sorry, I made a typo. I ment: only cells with dates in it, not text or empty cells

You won’t be able to do that with just Filter Datatable. Add a column named “Remove” and then For Each Row in Datatable through the data. Inside the loop, put an If with this as the condition:

(NOT CurrentRow(“BLOCKED_DATE”).ToString.Trim = “”) AND Date.TryParseExact(CurrentRow(“BLOCKED_DATE”).ToString.SubString(0,10),“MM/dd/yyyy”,Nothing,Globalization.DateTimeStyles.None,Nothing)

That returns True if it’s a valid date, false if not - but only if BLOCKED_DATE has a value.

In the Then block put an Assign with CurrentRow(“Remove”) = “No”
In the Else block put an Assign with CurrentRow(“Remove”) = “Yes”

Then use Filter Datatable to get rid of rows where Remove is Yes.

I think this might be the solution. however with
"(NOT CurrentRow(“BLOCKED_DATE”).ToString.Trim = “”) AND Date.TryParseExact(CurrentRow(“BLOCKED_DATE”).ToString.SubString(0,10),“MM/dd/yyyy”,Nothing,Globalization.DateTimeStyles.None,Nothing)

I receive an error:
If: Index and length must refer to a location within the string.
Parameter name: length

note: I have changed “MM/dd/yyyy” to “dd-MM-yyyy” because of a European date notation.

Change .SubString(0,10) to .Trim() instead. Substring() fails because there are strings with length less than 10 characters.

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