Bug 90100 - The function DAYS() returns non-interger values
Summary: The function DAYS() returns non-interger values
Status: CLOSED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.2.7.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-19 09:43 UTC by Mamoth
Modified: 2015-03-20 09:00 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Bug example (in sheet Calcul, cells H14 and I14) (608.52 KB, application/vnd.oasis.opendocument.spreadsheet)
2015-03-19 09:43 UTC, Mamoth
Details
simple case (25.96 KB, application/vnd.oasis.opendocument.spreadsheet)
2015-03-19 14:24 UTC, raal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mamoth 2015-03-19 09:43:12 UTC
Created attachment 114186 [details]
Bug example (in sheet Calcul, cells H14 and I14)

Hello.

I am doing operations with the functions DAYS(), INDIRECT() and ADDRESS() and have abnormal results.

I finally found that the problem comes from the value returned by the function DAYS(), which are not integers.

In the attached example, go to sheet 'Calcul' and cell H14 (coloured in dark pink). You may see that the cell contains the formula "=DAYS(D14;C14)" which returns as value "364,99999724537300000000000000".

Thus when I lated use this value to find a cell reference as done in the cell I14 (formula : "=ADDRESS($H14;B$22)"), the result is wrong ($H$364 instead of $H$365).

So far, I am working around this by replacing "=DAYS(D14;C14)" by "=round(DAYS(D14;C14))".
Comment 1 raal 2015-03-19 14:22:40 UTC
Hello,
when I change of cell format of H14, then I get value 365, but calculation is still bad.

DAYS work correct with dates 01/01/12 , 31/12/12. Problem is probably in chain of cells>
=DAYS(D14,C14) - problematic C14
lead to B4
lead to B73 - function if and index
lead to sheet MeteoFrance.G22
lead to B22
lead to B23

the problem is in one second in your date, see attachment. Closing as notabug, repair your data.
Comment 2 raal 2015-03-19 14:24:47 UTC
Created attachment 114190 [details]
simple case
Comment 3 m_a_riosv 2015-03-19 21:03:44 UTC
ODF 1.2 specifications.
6.10.6 DAYS
Summary: Returns the number of days between two dates
Syntax: DAYS( DateParam EndDate ; DateParam StartDate )
Returns: Number
Constraints: None
Semantics: Returns the number of days between two dates. If StartDate and EndDate are Numbers, this is EndDate – StartDate. If they are both Text, this is DATEVALUE(StartDate) – DATEVALUE(EndDate).

Can return not only whole days, but part of a day.

All values in column B of MeteoFrance sheet have decimals, I think the source of the issue.
Comment 4 Mamoth 2015-03-20 09:00:10 UTC
Hello.

Thanks for your help.

I have worked around this by applying ROUND to the dates themselves, thus getting rid of any hours:minutes:seconds offsets with the dates.

That ends up being something like : DAYS ( ROUND (Date 1); ROUND (Date 2)).

Consequently, I believe the bug can be closed as it is not one but a mistake on my side (and maybe a need for more explanation in the function wizard if I may suggest).

Thanks again.