DAX Date & Time - YEARFRAC function

Description

Calculates the fraction of the year represented by the number of whole days between two dates.

Syntax

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

参数

Sr.No. 参数与说明
1

start_date

The start date in datetime format.

2

end_date

The end date in datetime format.

3

basis

Optional.

The type of day count basis to use.

An integer between 0 and 4. If not an integer, the parameter will be truncated.

0 - US (NASD) 30/360.

1 - Actual/actual.

2 - Actual/360.

3 - Actual/365.

4 - European 30/360.

If omitted, default is 0.

Return Value

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

Remarks

You can use the YEARFRAC function to identify the proportion of a whole year's benefits or obligations to assign to a specific term.

DAX uses a datetime format to work with dates and times.

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

示例

= YEARFRAC ([InventoryDate], [UsageDate]) 

This formula returns a calculated column with fraction values representing InventoryDuration.

dax_functions_date_time.html