YEARFRAC function in Excel allows you to calculate the fraction of a year between two dates, making it useful for various financial and time-based calculations. It’s a straightforward way to determine the duration between two dates, which can be beneficial for understanding interest accruals, time periods, and more.

## Syntax

**YEARFRAC(start_date, end_date, [basis])**

## Arguments

start_date | The starting date of the period. |

end_date | The ending date of the period. |

[basis] | (Optional) An optional argument that specifies the day count basis to use. If omitted, it defaults to 0 (US NASD 30/360). You can choose from various basis options to determine the day count convention used in the calculation. For example, 0 represents US NASD 30/360, 1 represents Actual/Actual, and so on. |

## How to use

Let’s see how to use the YEARFRAC function with some examples:

**Example 1:** Calculate the fraction of a year between two dates:

1 |
=YEARFRAC("2023-01-01", "2023-06-30") |

This formula calculates the fraction of a year between January 1, 2023, and June 30, 2023, using the default basis (US NASD 30/360).

**Example 2:** Calculate the fraction of a year using a different day count basis:

1 |
=YEARFRAC("2023-01-01", "2023-06-30", 1) |

In this example, the formula calculates the year fraction using the Actual/Actual basis, giving you a more precise result.

**Example 3:** Calculate the year fraction between two specific dates and explain the basis:

1 |
=YEARFRAC("2023-01-01", "2023-12-31", 3) |

Here, we calculate the year fraction for the entire year 2023, using the “Actual/365 Fixed” basis, which considers the number of days in the year for the calculation.

YEARFRAC is a versatile function that helps you with a wide range of date-related calculations, including interest calculations, time duration, and more.