Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

DateTimeDiff result in decimal years?

rouxknee
6 - 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.

2 REPLIES 2
rouxknee
6 - 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!

VeronicaElse
8 - Asteroid

Hello, new to Alteryx,

 

I have a similar question, I am doing the DateTimeDiff and want the output to be in 2 place decimal. Mine is coming back in whole #s.

 

Thanks!

Labels