Bug 158694 - TEXT() function is not formatting months correctly.
Summary: TEXT() function is not formatting months correctly.
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.6.4.1 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 170543 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-12-14 05:47 UTC by Stephen Drake
Modified: 2026-01-30 15:23 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Spreadsheet demonstrating the bug. (24.63 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-12-14 05:50 UTC, Stephen Drake
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Drake 2023-12-14 05:47:43 UTC
Description:
I want to display the current month name from a date-formatted cell. I am using the TEXT function as follows: =TEXT(month(cell-id),"MMMM"). Cell-id is the cell containing the date. 

Steps to Reproduce:
1.Enter 1/1/23 in cell A1, 1/2/23 in A2, 1/3/23 in A3, etc until 1/12/23 in A12.
2.Enter =MONTH(A1) in B1, =MONTH(A2) in B2, and copy down to MONTH(A12) in B12.
3.Enter =TEXT(B1,"MMMM") in C1. Copy down to and including C12.

Actual Results:
C1 shows "December".
C2 - C12 all show "January".

Expected Results:
C1 should show January, C2 February, C3 March and so on down to C12 which should show December.


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Version: 7.6.4.1 (X86_64) / LibreOffice Community
Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1
CPU threads: 8; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: en-AU (en_AU); UI: en-GB
Calc: threaded
Comment 1 Stephen Drake 2023-12-14 05:50:16 UTC
Created attachment 191419 [details]
Spreadsheet demonstrating the bug.

If you need any further information or evidence from me, please contact me.
Comment 2 Mike Kaganski 2023-12-14 06:27:05 UTC
MMMM format code in TEXT function expects that the number that is being formatted is a *date* (i.e., a number of days since the date defined at Options->Calc->Calculate, by default 1899-12-30).

But you pass there a number returned by MONTH function, i.e. an integer between 1 and 12.

Your formula should be

=TEXT(cell-id,"MMMM")
Comment 3 Mike Kaganski 2026-01-30 15:23:28 UTC
*** Bug 170543 has been marked as a duplicate of this bug. ***