We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Date format

fieldew1
7 - Meteor

Hi,

 

I need a bit of help! 

I'm analyzing payment cards with their expiry dates. For some of them those exp dates come in the format ie. Jun-23, some 06/23. I'd like to convert any dates in the format 06/23 to Jun-23.

 

Example below

 

Expiry Date New Format

Jun-23          Jun-23

06/23            Jun-23

May-24          May-24

03/25             Mar-25

 

Any help will be much appreciated.

 

 

4 REPLIES 4
alexnajm
18 - Pollux
18 - Pollux

This formula works for the data provided: IF Contains([Field1], "/") THEN DateTimeFormat(DateTimeParse([Field1],"%m/%y"),"%b-%y") ELSE [Field1] ENDIF

Pilsner
13 - Pulsar

Hello @fieldew1 

To tackle this task, I would begin by identifying which records already match your desired format. The regex match function inside a formula tool can do this nicely. As you can see, I have specified that we are looking for 3 letters "\w{3}" followed by a dash "\-" followed by two numbers "\d{2}".

filter.png


Any records that match this format are already complete so we can simply set the new column equal to the old column:

Formula.png


Once you have done this, we need to consider the records that didn't match (those found in the false anchor of the filter tool). To handle these I think the easiest method is to first convert them into the data time format, using the specifiers MM/yy.

1.png
Then I would convert them from the date format into your desired format using another date time tool with the specifiers Mon-yy

2.png


By dropping unnecessary columns and unioning the results back together you get the following output.

final.png


I've attached the workflow with annotations below to try and assist further. 

Please let me know how you get on.

Regards - Pilsner



fieldew1
7 - Meteor

Thank you Both! Both solutions worked  😀

Pilsner
13 - Pulsar

Glad to hear, thank you!

Labels
Top Solution Authors