Bug 161591 - Formula Error in Calc
Summary: Formula Error in Calc
Status: RESOLVED INVALID
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
25.2.0.0 alpha0+
Hardware: All Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-15 20:06 UTC by Steve Ellsworth
Modified: 2024-06-16 02:48 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Ellsworth 2024-06-15 20:06:53 UTC
Description:
In calc when you use YEARFRAC and you have dates such as 12 Jan, 2020 in one cell and 20 Jun, 2020 in another cell, it should return 5.27. 

The actual formula would be =yearfrac(A2,B2)*12. 

When this is entered, it returns an error. 

That being said, if your dates are formatted as say, 04/02/2017, the formula works. It will work when there is a shortened month, such as APR, MAR, FEB, JAN. 

Actual Results:
#VALUE

Expected Results:
5.27


Reproducible: Always


User Profile Reset: No

Additional Info:
I can be reached at steven.ellsworth40@gmail.com
Comment 1 ady 2024-06-15 21:41:46 UTC
No repro on Windows. My guess is that the cells A2 and B2 are formatted as text instead of having the date format as:

DD MMM, YYYY


I would suggest for you to review the cell format and then re-introduce the dates; and then review whether the cells are still formatted as intended.
Comment 2 Steve Ellsworth 2024-06-16 00:17:53 UTC
I have a Windows machine which I will load the software onto, to test. I see you mentioned windows. Did you test this possible error on a Linux distro?
Comment 3 ady 2024-06-16 00:33:49 UTC
(In reply to Steve Ellsworth from comment #2)
> I have a Windows machine which I will load the software onto, to test. I see
> you mentioned windows. Did you test this possible error on a Linux distro?

There is no need to test with other OS – at least not ATM. Just check what I suggested in your own OS using the same file on which you based the report. Then please report back.
Comment 4 Steve Ellsworth 2024-06-16 00:42:54 UTC
I formatted the text as requested. The issue/error only presents itself using the format of 25 April, 2025. If I use 04/25/2025, it works as designed. I tried the date analysis using YEARFRAC and DATEDIF.
Comment 5 Steve Ellsworth 2024-06-16 01:35:10 UTC
I relooked at my data. In both Windows (Excel) and Libre Office, one cannot take the data of 12 Jan, 2025 have either the datedif or yearfrac and come up with the answer. Fairly certain it has to do with it being text within numbers.
Comment 6 ady 2024-06-16 01:54:06 UTC
Maybe I was not clear/specific enough. I am able to obtain the correct result using the date format mentioned in comment 0. This is the reason I posted instructions in comment 1.

The way I tested it was:
1. Format cells A2:B2 as YYYY-MM-DD
2. Introduce the dates:
2.1. A2: 2020-01-12
2.2. B2: 2020-06-20
3. C2: =12*YEARFRAC(A2;B2)
4. Format cells A2:B2 as DD MMM, YYYY


There might or might not be some problem when introducing the dates, but the function is correctly showing the expected result, and the cells show the expected date format.

Please review your steps (and the instructions). Please clarify whether there is some discrepancy.

Otherwise, someone else needs to attempt to reproduce the problem, or this is more a question for <https://ask.libreoffice.org> rather than a bug report.
Comment 7 Steve Ellsworth 2024-06-16 01:59:09 UTC
I really do appreciate your help :-). As you have shown, it would absolutely appear I would need to reformat. I am very much looking to use the software. For me, it was the last bit of reason for me to not switch over to Linux full time. 

Thanks again,

Steve
Comment 8 ady 2024-06-16 02:16:37 UTC
For a future report, it would help to attach a minimal sample file to the report, using the "Add an attachment" link in the web page of the bug report.

(In reply to Steve Ellsworth from comment #7)
> appear I would need to reformat.

I'm not sure I understand what exactly you mean by reformat.

Are the instructions working correctly for you? Are the cells displayed correctly and the formula showing the expected result?

IDK what's the exact procedure that you want/need to use, or how exactly you introduce the data. Are you importing the data from some other file?

I would suggest asking for help in the Ask site.

Is there some remaining issue? Should this report remain open?
Comment 9 Steve Ellsworth 2024-06-16 02:23:19 UTC
Maybe an incorrect syntax. Essentially, I would reformat the dates to accomodate the formula. 

I am good to go. 

thank you,

I do believe the comment/ticket can be close.