Bug 142920 - Workday function give bad results
Summary: Workday function give bad results
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.2.0.0.alpha0+
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-17 15:31 UTC by paulo g.
Modified: 2021-06-18 08:48 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
=DIATRABALHO(A4;B4;"25-12-2021") (11.84 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-06-17 15:33 UTC, paulo g.
Details

Note You need to log in before you can comment on or make changes to this bug.
Description paulo g. 2021-06-17 15:31:29 UTC
Description:
Workday function give bad results

Steps to Reproduce:
26-07-2021	A4
13-08-2021      B4

1. create function =DIATRABALHO(A4;B4;"25-12-2021")
2. test result


Actual Results:
26-07-2021	13-08-2021		106592


Expected Results:
26-07-2021	13-08-2021	15


Reproducible: Always


User Profile Reset: No


OpenGL enabled: Yes

Additional Info:
calc well
Comment 1 paulo g. 2021-06-17 15:33:09 UTC
Created attachment 172990 [details]
=DIATRABALHO(A4;B4;"25-12-2021")
Comment 2 Mike Kaganski 2021-06-17 15:53:01 UTC
This is not a bug.
As explained on WORKDAY spreadsheet function help [1]:

> The result is a date number that can be formatted as a date.
>
> WORKDAY(StartDate; Days [; Holidays])
>
> Days is the number of workdays. Positive value for a result after the start
> date, negative value for a result before the start date.

So the second parameter is not a date, but a number of days; the result is not a number of days, but a date. You expect the opposite, which is another spreadsheet function: NETWORKDAYS [2] (DIATRABALHOTOTAL in Portuguese).

[1] https://help.libreoffice.org/7.2/en-US/text/scalc/01/func_workday.html?DbPAR=CALC
[2] https://help.libreoffice.org/7.2/en-US/text/scalc/01/func_networkdays.html?&DbPAR=CALC
Comment 3 paulo g. 2021-06-18 08:40:07 UTC
(In reply to Mike Kaganski from comment #2)
> This is not a bug.
> As explained on WORKDAY spreadsheet function help [1]:
> 
> > The result is a date number that can be formatted as a date.
> >
> > WORKDAY(StartDate; Days [; Holidays])
> >
> > Days is the number of workdays. Positive value for a result after the start
> > date, negative value for a result before the start date.
> 
> So the second parameter is not a date, but a number of days; the result is
> not a number of days, but a date. You expect the opposite, which is another
> spreadsheet function: NETWORKDAYS [2] (DIATRABALHOTOTAL in Portuguese).
> 
> [1]
> https://help.libreoffice.org/7.2/en-US/text/scalc/01/func_workday.
> html?DbPAR=CALC
> [2]
> https://help.libreoffice.org/7.2/en-US/text/scalc/01/func_networkdays.
> html?&DbPAR=CALC

Thanks. The names of the functions may not be the best choice. I have to be more attention.
Comment 4 Mike Kaganski 2021-06-18 08:48:58 UTC
(In reply to paulo g. from comment #3)
> The names of the functions may not be the best choice.

The standard (English) name follows established standard naming for the functions, and I suppose that localization team also followed relevant Excel localized function name [1], which is a reasonable choice: having a different name would only introduce confusion, and prevent from easy reuse of formulas shared on Internet.

[1] https://support.microsoft.com/pt-br/office/diatrabalhototal-fun%C3%A7%C3%A3o-diatrabalhototal-48e717bf-a7a3-495f-969e-5005e3eb18e7