YEARFRAC

The result is the number of the years (including fractional part) between StartDate and EndDate.

note

This function is part of the Open Document Format for Office Applications (OpenDocument) standard Version 1.2. (ISO/IEC 26300:2-2015)


語法

YEARFRAC(StartDate; EndDate [; Basis])

StartDateEndDate 是兩個日期值。

Basis 由選項清單中選擇,同時表示年度的計算方式。

基準

計算

0 or missing

美國方法 (NASD),12 個月,每月 30 天

1

月中確實的天數,一年中確實的天數

2

月中確實的天數,一年有 360 天

3

月中確實的天數,一年有 365 天

4

歐洲方法,12 個月,每月 30 天


note

When entering dates as part of formulas, slashes or dashes used as date separators are interpreted as arithmetic operators. Therefore, dates entered in this format are not recognized as dates and result in erroneous calculations. To keep dates from being interpreted as parts of formulas use the DATE function, for example, DATE(1954;7;20), or place the date in quotation marks and use the ISO 8601 notation, for example, "1954-07-20". Avoid using locale dependent date formats such as "07/20/54", the calculation may produce errors if the document is loaded under different locale settings.


tip

Unambiguous conversion is possible for ISO 8601 dates and times in their extended formats with separators. If a #VALUE! error occurs, then unselect Generate #VALUE! error in - LibreOffice Calc - Formula, button Details... in section "Detailed Calculation Settings", Conversion from text to number list box.


範例

2008-01-01 到 2008-07-01 是 2008 年的幾分之幾?

=YEARFRAC("2008-01-01"; "2008-07-01";0) returns 0.50.

Date & Time Functions

DATE

[text/scalc/01/func_datedif.xhp#datedif not found].

DATEVALUE

DAY

DAYS

DAYS360

DAYSINMONTH

DAYSINYEAR

EASTERSUNDAY

EDATE

EOMONTH

HOUR

ISLEAPYEAR

[text/scalc/01/func_isoweeknum.xhp#isoweeknum not found].

MINUTE

MONTH

MONTHS

NETWORKDAYS

NETWORKDAYS.INTL

NOW

SECOND

TIME

TIMEVALUE

TODAY

WEEKDAY

WEEKNUM

WEEKNUM_ADD

[text/scalc/01/func_weeknum_ooo.xhp#weeknum_ooo not found].

WEEKS

WEEKSINYEAR

WORKDAY

WORKDAY.INTL

YEAR

YEARFRAC

YEARS

Please support us!