Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

DateTimeParse 2 digit year %y

Jonny
11 - Bolide

Hi Folks,

 

I need to convert same DB Date to Alteryx Date Format. I am puzzled by DateTimeParse not behaving as I would have expected. so reaching out for help.

 

My date in DB is like 1210601 - which should read as 2021-06-01

using DateTimeParse in formula as DateTimeParse(Right(ToString([Date despatched]),6),"%y%m%d")

it gives me 2106-01-01 - refer below screen shots.  The weird bit is that although I am using small "y" it still gives me a 4 digit year.

 

am I doing something wrong or is this a "feature"? 

Jonny_0-1633624323224.png

 

sample workflow to help ilustrate the problem:

Jonny_1-1633624449457.png

 

sample workflow attached. 

 

I know I could use a formula toDate left, right, and what not. But I really like DateTimeParse and want to know where I am getting it wrong.

 

Thank you!

 

 

4 REPLIES 4
atcodedog05
22 - Nova
22 - Nova

Hi @Jonny 

 

Add "20" at the beginning of the string to get it working

 

DateTimeParse("20"+Right(ToString([Date despatched]),6),"%Y%m%d")

 

Workflow:

atcodedog05_0-1633625087064.png

 

Hope this helps : )

Jonny
11 - Bolide

Legend @atcodedog05 ! that will do the trick. Thanks for the fast response!

But I still wonder, the difference between the "Y" and "y" when using DateTimeParse.

should it "y" read the input string as two digit year?

atcodedog05
22 - Nova
22 - Nova

Hi @Jonny 

 

I was guessing the same. But then I checked the documentation page and this appears to be a limitation.

 

atcodedog05_0-1633625515081.png

 

https://help.alteryx.com/20213/designer/datetime-functions

 

Hope this helps : )

atcodedog05
22 - Nova
22 - Nova

Hi @Jonny 

 

We can introduce a seperator using Regex and %y will work.

 

atcodedog05_0-1633625831810.png

 

Hope this helps : )

Labels