Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

REGEX_MATCH for validating date format

mszpot89
9 - Comet

I've made a control where end-user inputs date. I want to add a warning that would prompt whenever format is wrong.

The only accepted is "mm/d/yyyy". I tried to built and expression with regex_match but have challenge to combine functions into one solid expression.

 

 

flow.PNGflow 2.PNG

 

 

 

 

2 REPLIES 2
MarqueeCrew
20 - Arcturus
20 - Arcturus

 

How about this?

 

IIF(regex_match([#1],"[01]{0,1}\d\/[0-3]*\d\/20\d{2}"),1,0)

Cheers,

Mark

 

0 or 1: 0 or 1 occurrences (allows for months 1-9 plus 01-01)

\d: Allows for a second digit in the month

0-3: allows for days starting 00 through 39.

\/ is the / character

20 followed by any 2 numbers

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
mszpot89
9 - Comet

I modified the function to allow only one specific format "mm/d/yyyy" and only first day of month.

Also switching the 1,0 arguments at the end of IIF fixed the issue I had that whenever I entered different format alteryx still allowed it to be entered.

 

Below code works perfectly!

Thanks @MarqueeCrew for your help! I finally made first step in understanding the regexp syntax ;)

 

IsEmpty([#1])
or 
IIF(regex_match([#1],"(0[1-9]|1[0-2])\/([1]|[12]\d|3[01])\/[12]\d{3}"),0,1)
Labels