ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

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

how to check if a column contains valid date format

SamSurya
Asteroide

I hve a column having date as 30-Jun-20. this column has different date formats. I need to check if the date given is in the format listed below:

 

The valid values are the following: 'DDMMYYYY' , 'MMDDYYYY' , 'YYYYMMDD' , 'DD-MM-YYYY' , 'MM-DD-YYYY' , 'YYYY-MM-DD' , 'DD.MM.YYYY' , 'MM.DD.YYYY' , 'YYYY.MM.DD' , 'DD/MM/YYYY' , 'MM/DD/YYYY' , 'YYYY/MM/DD' , 'YYYY-MM-DDThh:mm:ss.000000000' , if not  than flag as "Not Valid" else "Valid"

 

 

Please help. 

15 RESPUESTAS 15
DavidP
17 - Castor
17 - Castor

You would do it with a formula like this. You'll have to test for every type of format in your list.

 

I'll add some more if I get a chance.

 

DavidP_0-1595417382793.png

 

DavidP
17 - Castor
17 - Castor

I've updated it now with all the options

 

DavidP_0-1595418718567.png

 

JosephSerpis
17 - Castor
17 - Castor

Hi @SamSurya you can do this with Regex match and also check that the date dosent exceed 12 months or the date go past 31 days. Let me know what you think?

SamSurya
Asteroide

Amazing..... I was not sure if DateTime Parse would work here ..... thanks ... for showing me new way. this works ... 🙂

SamSurya
Asteroide

Wow... Thanks a tonne... This works for me and yes, you gave me a thought, I do get data where dates are in valid format but not correct this check would indeed be really helpful. so is this possible with in Regex or do we need to have additional formula.

brendafos
Bola de fuego

Joseph -

 

Love your solution.

Thanks for another great example of the power of Regular Expressions!

SamSurya
Asteroide

Hi Joseph,

 

just one more help, could you please help me understanding ""^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$" .

 

Thanks 

Sam

SamSurya
Asteroide

Yeah.. indeed... I second that

JosephSerpis
17 - Castor
17 - Castor

Hi @SamSurya this link will help explain the Regex.

Etiquetas
Autores con mayor cantidad de soluciones