YEARFRAC Function

It calculates the difference between two dates and represents the fraction in decimal values.

Author: Elliot Meade
Elliot Meade
Elliot Meade
Private Equity | Investment Banking

Elliot currently works as a Private Equity Associate at Greenridge Investment Partners, a middle market fund based in Austin, TX. He was previously an Analyst in Piper Jaffray's Leveraged Finance group, working across all industry verticals on LBOs, acquisition financings, refinancings, and recapitalizations. Prior to Piper Jaffray, he spent 2 years at Citi in the Leveraged Finance Credit Portfolio group focused on origination and ongoing credit monitoring of outstanding loans and was also a member of the Columbia recruiting committee for the Investment Banking Division for incoming summer and full-time analysts.

Elliot has a Bachelor of Arts in Business Management from Columbia University.

Reviewed By: Kevin Henderson
Kevin Henderson
Kevin Henderson
Private Equity | Corporate Finance

Kevin is currently the Head of Execution and a Vice President at Ion Pacific, a merchant bank and asset manager based Hong Kong that invests in the technology sector globally. Prior to joining Ion Pacific, Kevin was a Vice President at Accordion Partners, a consulting firm that works with management teams at portfolio companies of leading private equity firms.

Previously, he was an Associate in the Power, Energy, and Infrastructure Investment Banking group at Lazard in New York where he completed numerous M&A transactions and advised corporate clients on a range of financial and strategic issues. Kevin began his career in corporate finance roles at Enbridge Inc. in Canada. During his time at Enbridge Kevin worked across the finance function gaining experience in treasury, corporate planning, and investor relations.

Kevin holds an MBA from Harvard Business School, a Bachelor of Commerce Degree from Queen's University and is a CFA Charterholder.

Last Updated:November 1, 2023

What is the YEARFRAC Function?

The YEARFRAC function in Excel calculates the difference between two dates and represents the fraction in decimal values.

While preparing the financial models, I always had this question: "I value the companies long after their year-end date. How do I project the cash flows 'after' the transaction date until the end of the next fiscal year?

I wasn't an Excel Geek back then, so I would pull out the calculator or visit those sketchy websites with tons of ads that gave the difference between the dates in terms of fractions.

The times have changed now, though. If the world order can change as American Investor Ray Dalio proposed, so can I.

This is the story about the YEARFRAC function and how it completely changed my approach to returning the difference between the dates as decimal numbers.

Let's see what the YEARFRAC function is, how to use the function along with a couple of examples.

Key Takeaways

  • The YEARFRAC is a Date and Time Function that returns the difference between two given dates as a fraction.
  • The function can determine a person's age, assets, etc.
  • It can also be used to adjust the Free Cash Flow to the Firms in the Discounted Cash Flow Model as per the transaction date.
  • The function accepts three arguments - starting date, ending date, and the day counts convention.
  • Dates can be input using the DATE function to avoid errors due to formatting issues.
  • Since the primary function only accepts values between 0 and 4, if you input a number greater than that, the function returns the #NUM! Error.
  • If the primary argument is non-numeric, we get the #NAME? or the #VALUE! Error.
  • If you input an invalid date, the function returns the #VALUE! Error. For example, if the start date is 1st January 1800 and the end date is 21st March 1903, the process will return the #VALUE! Error since the dates begin from 1st Jan 1900 in Excel.

YEARFRAC function Formula

The YEARFRAC is categorized as a Date and Time function that returns the difference between two dates as a decimal value.

For example, if you have two dates separated by 365 days, the result would equal one.

The function works on a simple principle - Find the difference between the two dates and divide the result by 365 days or the days in a single year.

The decimal number returned is the fractional representation of the day difference between the given dates.

The syntax for the function is:

=YEARFRAC(start_date, end_date, [basis])

where.

  • start_date - (required) the starting date for the given period
  • end_date - (required) the ending date for the given period
  • basis - (optional) day count basis, where 0 equals the default value.

The basis argument can only accept five different values as below:

Basis Argument
Basis Day Count
0 US (NASD) 30/360
1 Actual / Actual
2 Actual / 360
3 Actual / 365
4 European 30 / 360

How to use the YEARFRAC Function in Excel?

By this section, you already know what you need to do if you have two different dates in the dataset.

Suppose you have the data, as illustrated below:

Dates

All you need to do is begin with an equal sign in cell D3, type in the function name, and finally reference both dates. The formula will be =YEARFRAC(B3, C3), which gives the result 0.688889 in cell D3.

Date

By dragging down the formula till cell D7, we get

Fraction

If you feel you are getting too many digits after the decimal, you can shift the decimal point toward the right, which will finally give the difference between the dates in fractions as

Fraction

Since we have ignored the basic argument, Excel assumes the US(NASD) 30/ 360 convention meaning 30 days each month for a year consisting of 360 days.

This US(NASD) 30/ 360 convention was initially defined by the Financial Industry Regulatory Authority (FINRA).

Applied Example on how to use the YEARFRAC Function

You will most likely use the YEARFRAC function while preparing a company's Discounted Cash Flow Model. However, there are other use cases for the function, such as finding a person's age, assets, etc.

We can also use the function along with the IF statements, which will return two different results for the boolean values.

a) Discounting the Cash Flows to Present Value

Suppose that you prepare the company's three-statement financial model and the discounted cash flow model to calculate the stock price of the company.

Let's say you want to purchase the stock today, i.e., 16th November 2022. However, the company's financial year-end date is on 31st March.

Year

We see that the cash flow to the firm in 2023 equals $1444.0 million. However, we do need to remember that this forecasted number is for the financial period from 31st March 2022 to 31st March 2023.

Since we will be purchasing the stock on 16th November 2022, we will only focus on the FCFF after this date.

Here we could use the YEARFRAC function to calculate the difference between today's date and the year-end date. The multiple returns can be used to calculate the FCFF after the purchase of the stock till the fiscal year-end date.

The formula will be =YEARFRAC(B6, C6) in cell C7. We get the fractional value as 0.375 for 2023, which equals 1 for 2024 and 2025.

Thus, the cash flows based on the transaction will be:

Date

Finally, the adjusted cashflows can be used to calculate the stock price and determine whether it's undervalued or overvalued per its market price.

b) Finding the age of a person/asset

Let's assume that the bank wants to know the age of all applicants looking to borrow from the bank.

Due to its strict policies, the bank usually does not lend to anyone over 65. Suppose you have the borrower's birthdate, as illustrated below:

Names

Here, we will use the formula =INT(YEARFRAC(C3,TODAY())) in cell D3 and drag it down till cell D12, which gives the result:

Age

The TODAY function gives today's date, which the YEARFRAC function uses to find the fraction between both dates. Initially, the result we would get using these functions would be 59.49167 in cell D3.

However, after using the INT function, which returns the integer value for a number, we finally get the result as 59, which is the age for Gustavo Carson.

If the YEARFRAC function did not exist, we could also alternatively use the formula =YEAR(TODAY())-YEAR(C3), which will give us the same result for the age.

Ensure you change the format from 'date' to 'number' after you use the formula, or else you might get misleading results!

Other uses of the YEARFRAC function

There are other scenarios where the function can be used independently or in combination with some different process. If you are working on some project and need to track the time remaining till the deadline in terms of percentage, you can use a mix of YEARFRAC and TODAY functions.

The versatile IF statements allow you to return two results based on the fulfilled condition. You can leverage the function's ability and combine it with YEARFRAC to return customized results.

a. Calculating the percentage of the year completed

Let's say that your clients allocate you a couple of projects which need to be completed on the deadlines given to you.

Suppose that the projects' start date and end date are, as illustrated below:

Project

Firstly, we used the TODAY function in cell C3 and then added the days to the project to get the next consecutive start dates. For example, TODAY()+5 gives the start date of Project B as 21st November 2022.

We know that TODAY is a highly volatile function whose value will change if you open the file the next day. This way, the rest of your table's values automatically get updated.

Next, we will calculate the difference between the dates as the fraction using the formula =YEARFRAC(C3,D3), which gives the value in column E as

Start

We will create another column and paste special values in range E3:E7 as:

Date

Finally, to get the time remaining on the project, we will use the formula =E3/F3, which gives the time remaining on projects as follows:

Fraction

Suppose today's date is 11th March 2023; then the time remaining on the given projects will be:

Time

b. Using along with the IF Statements

The IF statements shouldn't need any introductions. Even beginner Excel users know what the IF function does and how useful it has been since immemorial.

In the previous example, we did find the borrowers' age, but that does not provide any meaningful insights as to whether to lend the loans to the borrowers.

In this case, we can use the IF statements to input a condition and assign two different customized text strings to the formula based on the result of that particular condition.

Suppose the data is as illustrated below:

Age

We will use the formula =IF(INT(YEARFRAC(C3, TODAY()))>65, "Loan cannot be offered", "Offer Loan") in cell D3 and drag it down till cell C12, which gives the result:

Below

We knew that the bank does not offer loans to borrowers above the age of 65 and has input it as a condition in the IF statements.

This way, whenever the borrower's age is above 65, we get the result' loan cannot be offered as a text string.

You can even input a formula that will calculate the loan amount for the borrower based on age. For example, if the period is near 65, the procedure returns a smaller loan amount, whereas a generation away from 65 will return an enormous loan amount for the borrower.

If the IF statements confuse you, another alternative you can use is the Conditional Formatting Tool.

Age

First, select the range D3:D12 and then click on the Conditional Formatting Tool or press the Alt + H + L + N.

We will format only the cells whose cell value is less than 65, i.e., the age limit for the loan.

Format

Once we click on Ok, we get the result as

Names

You can then add a filter to the table and sort the data according to the cell fill, which finally gives you all the borrowers who apply for the loan as

Age

Researched and authored by Akash Bagul | LinkedIn

Reviewed and edited by Parul Gupta | LinkedIn

Free Resources

To continue learning and advancing your career, check out these additional helpful WSO resources: