YEARFRAC issue

jh_0108

New Member
Joined
Apr 22, 2014
Messages
14
ABCYearfrac formulaoutput
11/10/201212/30/2015Yearfrac(A,C,1)3.1348391513
11/10/201211/10/201512/30/2015Yearfrac(A,B,1)+Yearfrac(B,C,1)3.1349329133

<tbody>
</tbody>

the date is in mm/dd/yyyy format

Anyone know why the outputs is different?

it happen when there is leap year. If column A are year 2013, the output for row 1 & 2 is the same.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
A
B
C
Yearfrac formula
output
11/10/2012
12/30/2015
Yearfrac(A,C,1)
3.1348391513
11/10/2012
11/10/2015
12/30/2015
Yearfrac(A,B,1)+Yearfrac(B,C,1)
3.1349329133

<tbody>
</tbody>

the date is in mm/dd/yyyy format

Anyone know why the outputs is different?

it happen when there is leap year. If column A are year 2013, the output for row 1 & 2 is the same.

OK... WHAT IS the fraction of a 'year'?
For some years, each day makes up 1/365th. On others it is 1/366th.
The number of days between November 10 2012 and December 20 2015 is 1145
1145/3.1348391513 is 365.25. Oh great. That is what YearFrac uses

OK... The number of days between November 10 2012 and November 10 2015 is 1095.
YearFrac seems to calculate that as 2.997947. WHAT... Lo, that's 1095/365.25. And there's the anomoly (or at least half of it)

The other half...
The number of days between November 10 2015 and December 30 2015 is 50. Great, 1095+50 = 1145.
YearFrac calculates that as 0.136986. Which means it's using 365 days for that portion.

The short answer...
Ber VEWWY CAREFOOL when using YearFrac.
 
Upvote 0
And just to confuse you more.
Think in your head what the fractional years are between November 10 1012 and December 30 2015.
Is it 3 years and a bit?
But what's the bit?

Ie, is it November 10 2012 until November 10 2015 PLUS November 11 2015 to December 30 2015? That is 3 years plus 50/365 (there are 365 days in 2015)
Or is it November 10 2012 intil December 30 2012 PLUS January 1 2013 ro December 30 2015? That is 50/366 plus 3 years (there are 366 days in 2012)


The reality is that there is NO correct answer.
 
Upvote 0
It doesn't really matter that there are very small differences. The formula provides a guide as to what proportion of a year is between two dates.
 
Upvote 0
I kinda agree.

Most would expect it to get the EXACT-points right, though...

{see my comment about 2.997947 above. That is exactly 3 years}
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,026
Members
449,061
Latest member
TheRealJoaquin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top