Alteryx Designer Desktop Discussions

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

Standardise date field format with leading zeros

RBF
7 - Meteor

I have records coming in from multiple combined files. In one field, some of the dates have leading zeroes where month/day <10, but others do not:

 

example: 
13.04.2023

9.8.2022

5.7.2022

28.02.2022

 

How can I standardise these to all be dd-mm-yyyy with leading zeros where applicable and covert to date format?

 

example desired output:

13.04.2023

09.08.2022

05.07.2022

28.02.2022

 

RBF_0-1687270962961.png

 

3 REPLIES 3
DataNath
17 - Castor

Hey @RBF, there's a couple of methods for parsing incoming dates into a standard format. My personal preference is a Formula tool with the DateTimeParse() function, where we tell Alteryx the format of the incoming string and it converts it into an ISO date format (YYYY-MM-DD, which is the only form Alteryx can work with as an actual Date data type). Here's how I'd do that for your case, where the following specifiers are used:

 

%d - 1 or 2 digit day

%m - months as numbers 1-12

%Y - year

 

DataNath_0-1687271541859.png

 

More info on those and more here: https://help.alteryx.com/20231/designer/datetime-functions

 

On the latter part of your request i.e. using dd.mm.yyyy as an output with Date data type, this isn't possible for the reason mentioned above. You'd have to have this as a String which we could do like so:

 

DataNath_1-1687271689470.png

 

Workflow attached - hope this helps

cjaneczko
13 - Pulsar

You should be able to use the DateTime tool with a custom option.

 

 

dd.MM.yyyy

 

cjaneczko_0-1687271784000.pngcjaneczko_1-1687271797070.pngcjaneczko_2-1687271812386.png

 

 

RBF
7 - Meteor

Worked great thanks

Labels