Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Date filter

rajputakansha
8 - 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

8 REPLIES 8
fmvizcaino
17 - Castor
17 - Castor

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.

Jonathan-Sherman
15 - Aurora
15 - Aurora

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

rajputakansha
8 - Asteroid

Hi @Jonathan-Sherman ,

 

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

 

Thank you!

rajputakansha
8 - 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!

Jonathan-Sherman
15 - Aurora
15 - Aurora

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!

Jonathan-Sherman
15 - Aurora
15 - Aurora

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.

fmvizcaino
17 - Castor
17 - Castor

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

Jonathan-Sherman
15 - Aurora
15 - Aurora

@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