Alteryx Designer Desktop Discussions

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

Convert YYMMDD number into Date

GAD318
5 - Atom

I am experiencing an issue with the DateTime function on Alteryx that I am hoping someone can help with. My data is formatted as numbers, with an example being 220221, representing the date 02/21/22 (mm/dd/yy). Can someone point to how I could convert that number to the date I used in the example? Please see the image below. 

 

I am thinking the problem could be that Alteryx is reading the number as a string, but since I am a rookie, I am not sure what would be the correct data type to format it as before feeding into the DateTime function.  

 

Date&Time Question.jpg

4 REPLIES 4
IraWatt
17 - Castor
17 - Castor

Hey @GAD318,

Just looking at the screenshot you have used little mm's <- this is for minutes not months. What you want is MM like this: yyddMM

 

DataNath
17 - Castor

How does this look @GAD318? There were some extra considerations because of the 6 digit input date but this should work and the formulas will also change the date as they need, format-wise, so you can just keep the input as numeric.

 

DataNath_0-1655309930395.png

 

Can also be rolled into one expression for simplicity:

 

DataNath_0-1655310224276.png

 

 

binuacs
20 - Arcturus

@GAD318 one way of doing this

 

binuacs_0-1655310025280.png

 

kathleenmonks
Alteryx
Alteryx

Hi @GAD318,

 

As @IraWatt mentioned, you would need an uppercase M for months, but the yy will also look for four digits which is also why you're not getting the result you expect. See this blurb from the datetime function documentation


"Because up to 4 digits are read for the year, formats that are intended to have only 2 digits without a separator, such as a 6-digit date stamp (for example, %y%m%d for data resembling 170522 for May 22, 2017), are still read as 4 digits. To work around this limitation, you can..."

 

I would recommend adding a formula before that adds some slashes to your string to account for this:

 

Substring([example],0,2) + "/" + Substring([example],2,2) + "/" + Substring([example],4,2)

Labels