Bug 104400 - File has a Day() function that works incorrectly in Calc yet correctly in Excel
Summary: File has a Day() function that works incorrectly in Calc yet correctly in Excel
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.1.6.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-04 20:02 UTC by JP
Modified: 2018-02-18 12:45 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
File showing a Day function issue starting on cell C5. (24.69 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2016-12-04 20:06 UTC, JP
Details

Note You need to log in before you can comment on or make changes to this bug.
Description JP 2016-12-04 20:02:05 UTC
Description:
I created a spreadsheet to use as a calendar.  On row 67 I changed from typing in every date to using =DAY($A67), where the first day of the week was in column A, the rest of the week was thus done by addition, DAY($A67+1) and so on.
That first day is wrong in my file.  If I create a new file it works correctly, so there must be a file error that is not detected.  This is an issue because it works in excel yet gives the wrong information in Calc.

Steps to Reproduce:
1. Load file
2. Go cell where error day is wrong
3. clear cell.  Type in =day(<cell>) and see error reproduced.
4. If you go to a new cell then day appears to work, but copying a nonworking cell and pasting somehow corrupts that newly pasted cell so that Day() subtracts 1.

Actual Results:  
reported Day is off by 1. This happens on different computers running Libreoffice.

Expected Results:
reported day should match the date.


Reproducible: Always

User Profile Reset: No

Additional Info:


User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
Comment 1 JP 2016-12-04 20:06:54 UTC
Created attachment 129305 [details]
File showing a Day function issue starting on cell C5.

This file is required to reproduce the issue.
Comment 2 GerardF 2016-12-05 09:31:03 UTC
No bug here.
Format cell as standard and you will get expexted result.
A6 contains date July 31th of 2016,
C6 contains =DAY(A6),
result of C6 formula is 31.

Format of C6 cell is "DD", so it returns the day of the 31 days after date origin which is set to 1899-12-30 in Calc. "1899-12-30"+31 → 1900-01-30
DAY("1900-01-30") = 30

You get 31 in Excel because Excel start one days later due that they incorrectly considers 1900 as a leap year.