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.
Solved! Go to Solution.
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
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)