community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

DateTimeDiff result in decimal years?

Meteoroid

Hello!

 

I'm using a formula to calculate the number of years between dates - what I want is the number of years to hundredths of a year.  This would be like using a YEARFRAC function in Excel.

 

Current formula: DateTimeDiff(DateTimeToday(), [Seniority Date], "years")

 

For [Seniority Date]  = 2001-08-20, the formula returns 16; I need it to return 16.24.

 

I tried using the following with no luck:

 

Round(DateTimeDiff(DateTimeToday(), [Seniority Date], "years"), .01)

 

EDIT: I thought about using days instead of years and dividing by 365 - that doesn't account for leap years, and the dates span decades.

Highlighted
Meteoroid

I ended up dividing the number of days by 365.25 rather than 365, which gets me to the correct number of years to the hundredth of a year (which is what I needed for this). 

 

Still, the ability to calculate decimal years from DateTimeDiff would be helpful!

Labels