Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Announcement | We'll be doing maintenance during the next 2-3 hours, which may impact your experience. Thanks for your patience as we work on improving the community!
SOLVED

Date filter

Asteroid

Hi, 

 

I have a very simple question!

How to I filter all the Date values from a column with Sting values included. My Date format is yyyy-mm-dd.

 

Thanks

Highlighted
Alteryx Certified Partner

Hi @rajputakansha ,

 

I have created 2 examples in how to filter dates. One way is by simply changing the data type, the other is by using a datetimediff function.

If this solves your issue please mark the answer as correct, if not let me know!

 

Hope this helps.

 

Best,

Fernando V.

Highlighted
Alteryx Partner

Hi @rajputakansha,

 

Is this what you're trying to achieve?

 

Input:

image.png

 

Output:

image.png

 

If so i would use a Regex_Match function inside a filter tool REGEX_Match([Column], '\d{4}-\d{1,2}-\d{1,2}')

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached my workbook for you to download if needed.

 

Regards,

Jonathan

Highlighted
Asteroid

Hi @Jonathan-Sherman ,

 

Can you please explain what we did here in the Regex formula?

 

Thank you!

Highlighted
Asteroid

Hi @fmvizcaino ,

 

Thanks for your response.

Can you please explain how changing the data type can filter the values.

 

Example;

COLUMN

abc

2019-12-12

bcd

2019-02-12

rfg

2018-01-10

 

 

This is my column from which I want to filer out the dates.

 

Thank you!

Highlighted
Alteryx Partner

Sure @rajputakansha, it's looking for cells that contain 4 digits followed by a hyphen, followed by between 1 and 2 digits, followed by a hyphen, followed by between 1 and 2 digits. The rows that match this are then coming out of the true anchor of the filter tool, and those that do not fulfill that condition are coming out of the false anchor.

 

If it's still unclear just let me know!

Highlighted
Alteryx Partner

I haven't changed the data type at all, it may be worthwhile doing it after the filter tool however. The filter tool is simply checking whether each row fits the condition i mentioned previously, 4 digits, hyphen, 1 or 2 digits, hyphen, 1 or two digits.

Highlighted
Alteryx Certified Partner

Hi @rajputakansha ,

 

By changing the data type, since Alteryx only consider as date strings with year-month-day format, it does the job automatically when using the filter tool as the 1st example.

 

Hope this helps.

 

Thanks,

Fernando Vizcaino

Highlighted
Alteryx Partner

@rajputakansha the reason I did not go down the same route as @fmvizcaino is because changing the data type would remove the (non date) rows from the data stream. Using a filter against a regex_match would still keep these "non date" rows available to be used later in the workflow if so desired.

Labels