Alteryx Designer Desktop Discussions

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

I want to add 2 character to the year like "20" for the year 16 so that it becomes 2016

meziane36u
7 - Meteor

how to add the 2 numbers to a number. for example I have a year in the form of 4 number 2010 and in the other file in the form of 2 number for example 10, and the same thing for the month, for the month of January it is 1, and for another file I have 01 (I will make the year in 4 digits and the month which contains a digit in 2 digits by adding 0 at the beginning)

7 REPLIES 7
atcodedog05
22 - Nova
22 - Nova

Hi @meziane36u 

 

You can implement this by these steps.

 

1. Covert the Year and month column to string

2. Year Column : "20"+[Year]

3. Month Column: Padleft([Month],2,"0") basically this add 0 to left when there is 1 digits

 

Hope this helps 🙂

atcodedog05
22 - Nova
22 - Nova

Hi @meziane36u 

 

Here is a workflow supporting the explanation. 

Workflow:

atcodedog05_0-1608045409019.png

 

Hope this helps 🙂 Feel to ask if you have any questions


If this post helps you please mark it as solution. And give a like if you dont mind 😀👍

leon2020
7 - Meteor

I saw this has been solved already, but I can't help myself but offer the possible solution to.... +2000 to the year number? 🙂


Joking aside, sometimes the best solutions are the simplest and in the heat of a moment, the obvious isn't always obvious! 🙂

atcodedog05
22 - Nova
22 - Nova

Happy to help 🙂 @meziane36u 

 

Cheers and Happy Analyzing 😀

 

Feel free to reach out if you face any issues 🙂

atcodedog05
22 - Nova
22 - Nova

Hi @leon2020 

 

How would you solve month problem 🙂 ?

meziane36u
7 - Meteor

thank you my problem is solved 😀

leon2020
7 - Meteor

Ha, I didn't see that bit!  I must admit, didn't know there is a PadLeft function.

 

Personally, I would have used IF [month number] < 10 then "0" + ToString([month number]) Else ToString([month number]) EndIf

 

or if [month number] was already a string IF ToNumber([month number]) < 10 then "0" + [month number] Else [month number] Endif

 

 

Labels