Alteryx Designer Desktop Discussions

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

datetimeformat makes column null

ShantanuDagar
8 - Asteroid

Hello,

 

I have a column MM/YY with 2023-03-01 as date.

 

I need only 03 that is month in that.

 

I am using formula datetimeformat([MM/YY], "%m") to get just the month.

 

But my whole column turns null after running this.

10 REPLIES 10
BS_THE_ANALYST
14 - Magnetar

@ShantanuDagar 
It seems fine for me:

BS_THE_ANALYST_0-1681290699126.png


Is the column definitely formatted as a date datatype?

BS_THE_ANALYST_1-1681290726696.png


All the best,
BS

martinding
13 - Pulsar

Hi @ShantanuDagar,

 

Are you updating you MMYY column or are you creating a new column?

mceleavey
17 - Castor
17 - Castor

Hi @ShantanuDagar ,

 

are you formatting the Month column as a date? If so, this will result in nulls.

If you format the column as a string you should get 03.

 

mceleavey_0-1681290779155.png

 

 

M.



Bulien

BS_THE_ANALYST
14 - Magnetar

@ShantanuDagar do you have trailing or leading spaces? If you do, you'll see that the column is formatted as a String datatype. I'd advise using a data cleanse tool to remove the spaces before you apply your formula tool if that's the case.

 

martinding
13 - Pulsar

Hi @ShantanuDagar ,

 

Please see attached:

 

Because your MMYY is a date type, when it gets updated in place, it will become Null, because 03 is not DateTime.

 

But if you create a new column, and use a string type, it will work.

martinding_0-1681290891347.png

 

Ben_H
11 - Bolide

Hi @ShantanuDagar,

 

Your column MM/YY is formatted as a date so it doesn't understand the output.

 

Try creating a new column, it should work then.

 

Regards,

 

Ben

Deano478
12 - Quasar

@ShantanuDagar  you can use the DateTimeMonth function like so:

 

Deano478_0-1681291042767.png

 

BS_THE_ANALYST
14 - Magnetar

@mceleavey Good spot.

You are trying to extract the month out, but this is not a Date Datatype. Hence, you are getting nulls i.e:

BS_THE_ANALYST_1-1681290955711.png


You can resolve this by creating a new column like @mceleavey did above or you can use the Multi-Field Formula tool to apply the formula to the column and simultaneously change the datatype to String. I.e:

BS_THE_ANALYST_2-1681291099863.png

 

All the best,
BS

 

ShantanuDagar
8 - Asteroid

Thanks all for quick solution.

 

Issue was that only, operating on date column without adding a new column.

Labels