Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Replacing Month number with month name

parria1
8 - Asteroid

I have a data set with the field mth with values 1 through 12. I changed the data type to a string.

I'm trying to replace the mth number with a month name, so 1=Jan, 2=Feb and so on.

I've tried the switch, IIF and If then else formulas on current field and they change the mth field name to Jan. not what i'm after

the formula editor does not recognize my mth field as a variable.

12 REPLIES 12
Parinita
6 - Meteoroid

 Hi parria1, 

 

I have a small doubt in the below formula that why we are using "0" here padleft(tostring([mth]),2,"0") -

 

datetimeformat("2000-"+padleft(tostring([mth]),2,"0")+"-01","%b")

 

DN
8 - Asteroid

datetimeformat requires the standard Alteryx datetime format 'yyyy-mm-dd'. Since the Year and Day are not relevant, we can provide a dummy value (hence 2000- and -01; note the "-" is for formatting to conform the datetime format)

padleft with zero (0) is used as follow: if month is one digit, padleft(tostring([mth]),2,"0") will return 01 02 03 when month=1,2,3 but keep 10 11 12 unchanged because already 2 characters.

ak2018
8 - Asteroid

I know this has been marked as solved, but have you attempted the DateTime tool? I use it to get the Month name  or to format the way you are specifying by using the Custom option. 

Labels