YEARFRAC DAX Function (Date and Time)
Returns the year fraction representing the number of whole days between start_date and end_date.
Syntax
Parameter | Attributes | 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
Fraction of the year.
Remarks
If the argument is a string, it is translated into a datetime value using the same rules applied by the DATEVALUE function.
Examples
YEARFRAC can be used to compute the current age of a customer based on the difference between the current day and the customer’s birthdate, but because of a bug it is suggested to use another technique (also faster) based on quotient and floor, as described in related content.
Related articles
Learn more about YEARFRAC in the following articles:
-
Correct calculate of age in DAX from birthday
Consider alternative to YEARFRAC in order to get the right age based on birthday because of bugs in YEARFRAC. » Read more
Related functions
Other related functions are:
Last update: Feb 25, 2021 » Contribute » Show contributors
Contributors: Alberto Ferrari, Marco Russo
MSDN documentation: https://docs.microsoft.com/en-us/dax/yearfrac-function-dax