# YEARFRACDAX Function (Date and Time)

Returns the year fraction representing the number of whole days between start_date and end_date.

## Syntax

YEARFRAC ( <StartDate>, <EndDate> [, <Basis>] )
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.
0 (default) : US (NASD) 30/360
1 : Actual/actual
2 : Actual/360
3 : Actual/365
4 : European 30/360

## Return values

Scalar A single decimal value.

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.

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.

» 1 related article
» 3 related functions

## Examples

```--  DATEDIFF computes the delta between two dates, using different units of measure
--  YEAFRAC returns the delta as a fraction (in years)
EVALUATE
VAR StartDate =  DATE ( 2011, 01, 01 )
VAR EndDate =    DATE ( 2012, 12, 15 )
RETURN
{
( "DATEDIFF Year",     DATEDIFF ( StartDate, EndDate, YEAR ) ),
( "DATEDIFF Quarter",  DATEDIFF ( StartDate, EndDate, QUARTER ) ),
( "DATEDIFF Month",    DATEDIFF ( StartDate, EndDate, MONTH ) ),
( "DATEDIFF Day",      DATEDIFF ( StartDate, EndDate, DAY ) ),
( "Subtraction",       INT ( EndDate - StartDate ) ),
( "YEARFRAC",          YEARFRAC ( StartDate, EndDate ) )
}
```
Value1 Value2
DATEDIFF Year 1.00
DATEDIFF Quarter 7.00
DATEDIFF Month 23.00
DATEDIFF Day 714.00
Subtraction 714.00
YEARFRAC 1.96
```--  The default of YEARFRAC is "US 30/360"
EVALUATE
VAR StartDate =  DATE ( 2010, 01, 01 )
VAR EndDate =    DATE ( 2011, 12, 15 )
RETURN
{
( "YEARFRAC",       YEARFRAC ( StartDate, EndDate ) ),
( "Number of days", INT ( EndDate - StartDate ) ),
( "YEARFRAC *365",  YEARFRAC ( StartDate, EndDate ) * 365 )
}
```
Value1 Value2
YEARFRAC 1.96
Number of days 713.00
YEARFRAC *365 713.78
```--  Different standards produce different fractions
--  YEAFRAC is intended as a financial function, following the required
--  standard of 30/360.
EVALUATE
VAR StartDate =  DATE ( 2011, 01, 01 )
VAR EndDate =    DATE ( 2011, 12, 15 )
RETURN
{
( "YEARFRAC US 30/360",       FORMAT ( YEARFRAC ( StartDate, EndDate, 0 ), "0.0000" ) ),
( "YEARFRAC Actual / Actual", FORMAT ( YEARFRAC ( StartDate, EndDate, 1 ), "0.0000" ) ),
( "YEARFRAC Actual / 360",    FORMAT ( YEARFRAC ( StartDate, EndDate, 2 ), "0.0000" ) ),
( "YEARFRAC Actual / 365",    FORMAT ( YEARFRAC ( StartDate, EndDate, 3 ), "0.0000" ) ),
( "YEARFRAC EU 30/360",       FORMAT ( YEARFRAC ( StartDate, EndDate, 4 ), "0.0000" ) )
}
```
Value1 Value2
YEARFRAC US 30/360 0.9556
YEARFRAC Actual / Actual 0.9534
YEARFRAC Actual / 360 0.9667
YEARFRAC Actual / 365 0.9534
YEARFRAC EU 30/360 0.9556

## Related functions

Other related functions are:

Last update: Aug 3, 2024     » Show contributors

Contributors: Alberto Ferrari, Marco Russo

Microsoft documentation: https://docs.microsoft.com/en-us/dax/yearfrac-function-dax

# Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

# Row Context

This expression is executed in a Row Context. Click to read more.

# Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

# Not recommended

The use of this parameter is not recommended.

# Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

# Volatile

A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.

# Deprecated

This parameter is deprecated and its use is not recommended.

# DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

### Contribute

Want to improve the content of YEARFRAC? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.