Alteryx Designer Desktop Discussions

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

Age in Year-Month-Day Format

AJ-CH
8 - Asteroid

Hello Alteryx Users, 

I am looking for the solution on how to calculate the age in 16years, 5 months, 21 Days format  (Years, Months, Days) from Birthdate field (the data is in this format 1971-10-25 00:00:00)

Thanks  

5 REPLIES 5
CharlieS
17 - Castor
17 - Castor

I use three sequential formulas to return the years/months/days past since the date entered. The DateTImeDiff( function has the Floor( function built in so only integer values are returned. This information is the key to the method below. 

 

Years:

DateTimeDiff(
DateTimeToday()
,[Birthday]
,"Years")

 

Months:

DateTimeDiff(
DateTimeToday()
,DateTimeAdd([Birthday],[Years]*12,"Months")
,"Months")

 

Days:

DateTimeDiff(
DateTimeToday()
,DateTimeAdd([Birthday],([Years]*12)+[Months],"Months")
,"days")

 

Check out the attached workflow to see this in action. 

AJ-CH
8 - Asteroid

thanks @CharlieS 

Ar13f
10 - Fireball

Dear @CharlieS 

 

I hope you and family in good health ... 

 

Would you mind explaining the meaning of the formula below, particularly for the "months" and "days"? (in particular, the blue one)

 

Years:

DateTimeDiff(
DateTimeToday()
,[Birthday]
,"Years")

 

Months:

DateTimeDiff(
DateTimeToday()
,DateTimeAdd([Birthday],[Years]*12,"Months")
,"Months")

 

Days:

DateTimeDiff(
DateTimeToday()
,DateTimeAdd([Birthday],([Years]*12)+[Months],"Months")
,"days")

 

really appreciate for your explanation ....

CharlieS
17 - Castor
17 - Castor

Hi @Ar13f 

 

The expressions above are meant to be executed in that order. The reason is that subsequent expressions use the field above. Years are calculated first. Only after years are done, can that result be used to determine the months. 

 

Basically we're taking the largest steps first (years), then using that result to take the next step (month), and after both of those are done we'll add the minutes. Does that make sense? 

Ar13f
10 - Fireball

Dear @CharlieS 

 

Thank you for your explanation ... 

Labels