Alteryx Designer Desktop Discussions

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

DateTimeParse does not parse leading two digit year

EYamada
7 - Meteor

I have a string yymmdd and the datetimeparse formula is not parsing the leading two digit year.  Please see details below;

 

Input:

Field 1
180118

 

Formula: DateTimeParse([Field1],"%y%m%d")

 

Conv Error:  DATETIMEPARSE: Cannot convert "180118" to a date/time with format "%y%m%d": Month number is out of range 1..12: '18'

 

Any thoughts what is going wrong here?

2 REPLIES 2
echuong1
Alteryx Alumni (Retired)

Part of the issue revolves around how Alteryx recognizes two digit years. 

 

echuong1_0-1579291006747.png

 

Try separating each section via a formula and then use the todate() function. You can also concatenate "20" to the beginning of your string and then use your conversion formula. 

 

todate("20" + left([Field 1],2) + "-" + right(left([Field 1],4),2) + "-" + right([Field 1],2))

 

DateTimeParse(("20" + [Field 1]),"%y%m%d")

 

See attached for an example. Let me know if that works!

Jonathan-Sherman
15 - Aurora
15 - Aurora

Similar to the route @echuong1 wen't down i would add 20 in front of the string and use the DateTimeParse() function:

 

DateTimeParse('20' + ToString([Field 1]),'%y%m%d')

 

image.png

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached my workflow for you to download if needed.

 

Regards,

Jonathan

Labels