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.
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.