Join the Alteryx Community’s Maveryx Summer Cup event! Compete, network with others, and earn your gold through a series of challenges from July 24th to August 11th. Learn more about the event here.

Alteryx Designer Desktop Discussions

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

Double Year column needs to be converted to Calendar Year

Adam_B
8 - Asteroid

Hi, 

I have a column named YEAR that is coming in as "Double" Column type.  I need to convert it to a Calendar year column type. So far I have used this formula:

 

Adam_B_1-1681757648569.png

 

Adam_B_0-1681757625179.png

 

But I am receiving an error. 

 

Please assist, thank you, 

Adam 

10 REPLIES 10
gaoa
11 - Bolide

Hi @Adam_B

A small change to your formula: DateTimeParse(ToString([Year]),"%Y") let me know if it works.

Adam_B
8 - Asteroid

I am getting this error

Adam_B_0-1681759666855.png

 

gaoa
11 - Bolide

Ah I see. Creating new column in Formula tool should fix this!

Adam_B
8 - Asteroid

@gaoa Ok, that worked but now I am getting a full date, I just want the YEAR (YYYY). 

Adam_B_0-1681760104091.png

 

 

binuacs
20 - Arcturus

@Adam_B When you take the parts of the date it will be always numeric. I mean if you have the [Year] field in numeric type (double or int) that is correct. Is there any reason why you are changing your [Year] field to Calendar Year? If you convert the given year into a calendar year also you will get the same numeric data type

 

binuacs_0-1681760187711.png

 

Adam_B
8 - Asteroid

@binuacs I have an excel xlsx file coming in with YEAR as the whole year (ex. 2023), Alteryx is showing it as Double, which in turn when I attach my data source to Tableau, it sees it as a string, I need it as a calendar year.  

Adam_B_0-1681760799110.png

 

This formula still provides the whole date as  , 

Adam_B_1-1681760833424.png

Adam_B_2-1681760882851.png

 

I just need the year. 

 

binuacs
20 - Arcturus

@Adam_B you missed the DateTimeYear() function, can you update your formula like the below highlighted in yellow?  

 

DateTimeYear(DateTimeParse(ToString([Year])+'0101','%Y%m%d'))

 

binuacs_0-1681761093776.png

 

Adam_B
8 - Asteroid

@binuacs Thank you...again :)

binuacs
20 - Arcturus

@Adam_B If you want the same field to convert use the Multi-Field tool

 

binuacs_1-1681761250208.png

 

Labels