YEARFRAC

Updated on

YEARFRAC is a DAX function that returns the fraction of the year represented by the number of whole days between two dates.

Syntax

YEARFRAC(
   StartDate,
   EndDate,
   Basis
)
Argument Properties Description
StartDate The start date in datetime format.
EndDate The end date in datetime format.
Basis Optional The type of day count basis to use.

Return Values

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

Remarks

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

Example 1

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

= YEARFRAC(Orders[TransactionDate],Orders[ShippingDate])

Example 2

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.

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/dax/yearfrac-function-dax

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy