Bug 146167 - =INDEX returns unknown numbers when a column with date formatted data is in the cells.
Summary: =INDEX returns unknown numbers when a column with date formatted data is in t...
Status: CLOSED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.2.3.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Calc-Function
  Show dependency treegraph
 
Reported: 2021-12-10 14:50 UTC by GlenArven
Modified: 2022-05-24 15:06 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Spredsheet with bug displayed (9.47 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-12-10 14:50 UTC, GlenArven
Details
2nd Spreadsheet (12.05 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-12-13 13:22 UTC, GlenArven
Details

Note You need to log in before you can comment on or make changes to this bug.
Description GlenArven 2021-12-10 14:50:16 UTC
Created attachment 176844 [details]
Spredsheet with bug displayed

=INDEX(Sheet1.A1:$B$10) 
or
=INDEX(Sheet1.$A1:$A10;1;1)

With date formatted data in the cells returns unknown numbers in the A2 and A3 cells. As demonstrated below. I rebooted my pc to make sure my memory was working correctly. Nothing changed.

Date
44538
44536
12/04/2021
12/01/2021
11/29/2021
11/27/2021
11/24/2021
11/22/2021
11/20/2021
11/17/2021
11/15/2021
11/13/2021
11/10/2021
11/08/2021
11/06/2021
11/03/2021
11/01/2021
10/30/2021
10/27/2021
10/25/2021
10/23/2021
10/20/2021
10/18/2021
10/16/2021
10/13/2021
10/11/2021
10/09/2021
10/06/2021
10/04/2021
10/02/2021
09/29/2021
Comment 1 GlenArven 2021-12-10 14:56:58 UTC
I just downloaded the attachment and it displayed correctly. I can recreate the described issue. But saving, closing and reopening seems to make it go away.
Comment 2 Roman Kuznetsov 2021-12-12 21:33:40 UTC
Could you repro the problem from scratch in a new Calc spreadsheet?
Comment 3 GlenArven 2021-12-13 13:22:01 UTC
Created attachment 176900 [details]
2nd Spreadsheet

This file does not exibit the same behavior as described in the original post. But, it does show how INDEX is not working correctly  with date formatted columns or cells.
Comment 4 QA Administrators 2021-12-14 04:26:28 UTC Comment hidden (obsolete)
Comment 5 Eike Rathke 2022-05-24 15:05:59 UTC
I don't see anything wrong opening the first document either.

With the second document the date displayed in Index1.B2 (1899-12-31 in whatever current locale's date format of DD/MM/YYYY) is the value 1 (obtained by =INDEX($Main.B2:$C$27;1;1)) explicitly formatted as date, which is already saved in the file as formula result 
office:value-type="date" office:date-value="1899-12-31" calcext:value-type="date"
with table:style-name="ce1" which is style:data-style-name="N36" which is

    <number:date-style style:name="N36" number:automatic-order="true">
      <number:month number:style="long"/>
      <number:text>/</number:text>
      <number:day number:style="long"/>
      <number:text>/</number:text>
      <number:year number:style="long"/>
    </number:date-style>

I don't see anything wrong.

I assume the cell Index1.B2 was created by copy-pasting Index1.A2 that copied the format along. Assign the General number format to B2 and you'll see.

Fwiw, the "unknown numbers" 44538 and 44536 in A2 and A3 of the original description are the date serial numbers of 2021-12-08 and 2021-12-06 just formatted as General (or any other number) instead of date.

I tried to reproduce by entering such formulas taking indexed values of date cells in unformatted cells but nothing wrong, date formats were applied automatically.

I assume the date formats of the two cells mentioned were simply cleared after entering the formula (e.g. by hitting Ctrl+M).

Closing as works-for-me.