--- a/scaddins/source/analysis/analysis.cxx +++ b/scaddins/source/analysis/analysis.cxx @@ -450,7 +450,14 @@ else mode = getDateMode(xOpt, rMode); // Restrict the observed1900 compatibility calendar to YEARFRAC itself. // Other financial functions retain their separate native conventions. - double fRet = GetYearFrac(nullDate, nStartDate, nEndDate, mode, + // Separate Excel 16.88 observations show that YEARFRAC on a 1904 + // workbook applies the 1462-day epoch displacement twice. Match this + // observed compatibility behavior only for trusted Excel imports; keep + // source-system range validation, ODS and other functions unchanged. + const sal_Int32 excelEpoch = DateToDays(30, 12, 1899); + const sal_Int32 yearfracEpoch = excel && nullDate == DateToDays(1, 1, 1904) + ? nullDate + (nullDate - excelEpoch) : nullDate; + double fRet = GetYearFrac(yearfracEpoch, nStartDate, nEndDate, mode, tabmorphAnalysisExcel1900(nullDate)); return finiteOrThrow(fRet); }