Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Calculating Fractions of Years.

Calculating Fractions of Years

by Allen Wyatt
(last updated January 24, 2015)

3

One of the types of data that Excel allows you to store is, of course, dates. At some point you may wish to perform some calculations with the dates in your worksheet. It is not uncommon to need to figure out the percentage of a year represented by the difference between two dates. Excel allows you to calculate this easily using the YEARFRAC worksheet function. This function is part of the Analysis ToolPak provided with Excel.

To use the function, all you need to do is provide two dates and a value that specifies how Excel should calculate the fractional year:

=YEARFRAC(DateOne, DateTwo, Basis)

The dates used by YEARFRAC can be either static dates, or they can be references to cells that contain dates. The Basis value ranges between 0 and 4, with 0 being the default. The following are the different meanings for the Basis:

Basis Meaning
0 US 30/360
1 Actual/actual
2 Actual/360
3 Actual/365
4 European 30/360

You should note that if the YEARFRAC function does not work on your system, it means you have not installed or enabled the Analysis ToolPak. To enable it, follow these steps:

  1. Choose Add-Ins from the Tools menu. Excel displays the Add-Ins dialog box.
  2. Make sure the Analysis ToolPak option is selected.
  3. Click on OK.

If you did not see an Analysis ToolPak option in step 2, it means that you did not install the option when you first installed Excel. You can rerun the Excel Setup program and choose to install the option. You must then enable the add-in, and you can use the function.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2562) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Calculating Fractions of Years.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Determining Word Versions of Documents

If you know where to look, you can figure out which version of Word was last used to work on a document. It takes some ...

Discover More

Conditionally Formatting an Entire Row

Need to conditionally highlight an entire row based on the contents of a single cell in each row? This tip explains how you ...

Discover More

Rounding To the Nearest Even Integer

Do you need your numbers to be rounded to an even integer value? How you accomplish the task depends on the nature of the ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (menu)

Numbers in Base 12

Different professions use numbers in entirely unique ways. You may need to come up with a number that represents the number ...

Discover More

Selecting Random Names

Got a tone of names from which you need to select a few random names? There are several ways you can extract what you need; ...

Discover More

Iterating Circular References

Does your data require that you perform calculations using circular references? If so, then you'll want to be aware of the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is seven minus 2?

2016-07-23 07:01:55

Peter

I have now resolved the issue. Somehow the add-ins for CSAPak had been unchecked. I have now checked them again.


2016-07-22 14:39:23

Michael

If this is exactly how you have it entered then a couple of parentheses (on end) were probably deleted inadvertently

Try

=YearFrac(F4,(Today()))

It works in my version anyway Excel 2007


2016-07-20 03:18:31

Peter

I had a formula in Excel 2003 which I entered only a few weeks ago. Today the formula returns a #NAME? error. It doesn't recognise "=YEARFRAC" anymore, but only when used with the "TODAY()" value. The result takes a person's date of birth from today's date to give an age in Number to 2 decimal places as formatted for the cell.

=YEARFRAC(F4,(TODAY()

This works in Google Spreadsheets. I uploaded to same spreadsheet to Google where it works without errors. Until recently it worked for Excel 2003.

An alternative formula for those who have died using the YEARFRAC value like
"=YEARFRAC(B$,C4)" taking the person's date of birth and date of death to return an age in 2 decimal places still works.

Does Microsoft kludge their older programs in their periodic updates to force users to upgrade?


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.