Bug 60912 - WEEKNUM_ADD fails when second parameter is omitted
Summary: WEEKNUM_ADD fails when second parameter is omitted
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
(earliest affected)
3.5.4 release
Hardware: x86-64 (AMD64) Linux (All)
: medium minor
Assignee: Not Assigned
Depends on:
Blocks: Calc-Function
  Show dependency treegraph
Reported: 2013-02-15 17:10 UTC by Colin Fletcher
Modified: 2021-06-14 10:46 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:

Excel file using WEEKNUM_ADD (34.00 KB, application/vnd.ms-excel)
2013-02-19 14:13 UTC, Colin Fletcher

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Fletcher 2013-02-15 17:10:35 UTC

Comment 1 Colin Fletcher 2013-02-15 17:13:40 UTC
When opening an Excel spreadsheet file where the WEEKNUM_ADD function has been used with only one parameter, an Err:504 occurs.

Excel permits the use of WEEKNUM add with only one parameter, in which case the second "ReturnType" parameter defaults (I believe) to 1, meaning "week beginning on a Sunday"
Comment 2 Julien Nabet 2013-02-16 17:37:35 UTC
Colin: did you try with a more recent LO version (last one is 3.6.5 for 3.6 branch and there's first 4.0 release available)?

If you can still reproduce this, could you attach a simple file which includes this function so we can test it?
Comment 3 Colin Fletcher 2013-02-19 14:11:06 UTC
To clarify, I first observed this in LibreOffice 
Build ID: 350m1(Build:2), on Debian testing.

I've also installed the .deb packages for, and the same error occurs. I haven't yet tried 4.0.0, but I'll do so when I can.

I'll upload an Excel file contianing WEEKNUM_ADD with both one and two parameters in a moment.
Comment 4 Colin Fletcher 2013-02-19 14:13:11 UTC
Created attachment 75112 [details]
Excel file using WEEKNUM_ADD

A file containing uses of WEEKNUM_ADD with both one and two parameters.
Comment 5 Colin Fletcher 2013-02-24 15:52:13 UTC
The one-parameter version of WEEKNUM_ADD in the attached Excel file fails in the same way in LibreOffice Version (Build ID: 7545bee9c2a0782548772a21bc84a9dcc583b89).
Comment 6 Julien Nabet 2013-02-24 21:41:06 UTC
On pc Debian x86-64 with master sources updated today, I can confirm the behaviour.

I thought than just by adding a default value in scaddins/source/analysis/analysis.cxx would work, 
line  591 sal_Int32 SAL_CALL AnalysisAddIn::getWeeknum( constREFXPS& xOpt, sal_Int32 nDate, sal_Int32 nMode ) THROWDEF_RTE_IAE
but it didn't.

Now I don't know if it's a bug or an enhancement.

Noel: What do you think about this one?
Comment 7 QA Administrators 2015-04-19 03:20:34 UTC Comment hidden (obsolete)
Comment 8 Colin Fletcher 2015-04-29 17:22:03 UTC
This bug still exists in LibreOffice

I've tested the version downloaded from here:
Comment 9 QA Administrators 2016-09-20 09:37:22 UTC Comment hidden (obsolete)
Comment 10 Colin Fletcher 2016-11-14 22:38:48 UTC
This bug still exists in LibreOffice version (Build ID: 1:5.2.3~rc1-4 in Debian testing).
Comment 11 QA Administrators 2017-11-15 09:15:35 UTC Comment hidden (obsolete)
Comment 12 QA Administrators 2020-10-21 04:22:51 UTC Comment hidden (obsolete)
Comment 13 Andreas Heinisch 2021-04-15 13:35:09 UTC
If I open the attached file, LO converts the functions to WEEKNUM_EXCEL2003 which needs the first day of the week. The function WEEKNUM itself behaves as requested. If I use a newer version of Excel in order to create a test file, they are converted to WEEKNUM.

So for better compatibility use WEEKNUM as stated also in the documentation:

Imho, we should close this bug, but if this feature is requested, we could easily change the required parameter to an optional one.