Calculates the fraction of the year represented by the number of whole days between two dates. Use the YEARFRAC worksheet function to identify the proportion of a whole year’s benefits or obligations to assign to a specific term.


YEARFRAC (<start_date>, <end_date>, <basis>)


start_dateThe start date in datetime format.
end_dateThe end date in datetime format.
basis(Optional) The type of day count basis to use. All arguments are truncated to integers.

Basis – Description

0 – US (NASD) 30/360

1 – Actual/actual

2 – Actual/360

3 – Actual/365

4 – European 30/360

Return value

A decimal number. The internal data type is a signed IEEE 64-bit (8-byte) double-precision floating-point number.


In contrast to Microsoft Excel, which stores dates as serial numbers, DAX uses a datetime format to work with dates and times. If you need to view dates as serial numbers, you can use the formatting options in Excel.

If start_date or end_date are not valid dates, YEARFRAC returns an error.

If basis < 0 or if basis > 4, YEARFRAC returns an error.


The following example returns the fraction of a year represented by the difference between the dates in the two columns, TransactionDate and ShippingDate:



The following example returns the fraction of a year represented by the difference between the dates, January 1 and March 1:

=YEARFRAC("Jan 1 2007","Mar 1 2007")  

Use four-digit years whenever possible, to avoid getting unexpected results. When the year is truncated, the current year is assumed. When the date is or omitted, the first date of the month is assumed.

The second argument, basis, has also been omitted. Therefore, the year fraction is calculated according to the US (NASD) 30/360 standard.

See also

Date and time functions (DAX)
WEEKNUM function (DAX)
WEEKDAY function (DAX)

***** Related Blog Posts *****
60 Page DAX Formula Reference Guide Download Now Available
Show Only Top Or Bottom Results Using Ranking Formula Techniques – Power BI & DAX

***** Related Video Tutorials *****
Ultimate Beginners Guide to DAX

What Is DAX? & Why Do You Need To Learn It – (1.2) Ultimate Beginner Guide to DAX
Formula Syntax, Comments & Variables – (1.6) Ultimate Beginners Guide to DAX
Examples Of Advanced DAX – (1.18) Ultimate Beginners Guide to DAX

***** Related Course Modules *****
Ultimate Beginners Guide to DAX
Mastering DAX Calculations
Solving Analytical Scenarios w/ Power BI and DAX
DAX Formula Deep Dives
Advanced DAX Combinations

***** Related Support Forum Posts*****
Mastering DAX Calculations: What Is DAX?
Understanding DAX Formula
Developing Complex Dax functions
Data Types And Operators

Leave a Reply

Your email address will not be published. Required fields are marked *